Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/phpredis/phpredis.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormichael-grunder <michael.grunder@gmail.com>2014-12-05 01:29:56 +0300
committermichael-grunder <michael.grunder@gmail.com>2015-05-06 01:05:30 +0300
commita271c4852cb1dd712fd14ea01ff90a38bf626558 (patch)
tree0c86c188fe9adf0ffe5c00b7b2db062299324955 /redis_cluster.h
parent48e6e67a8286ac2aab95132763bc78af508b9e90 (diff)
Initial commit incorporating a "readonly" flag.
We may want to configure phpredis such that it will attempt to fall back to a given master's slave, if the master were to go down (and the command is read only).
Diffstat (limited to 'redis_cluster.h')
-rw-r--r--redis_cluster.h6
1 files changed, 4 insertions, 2 deletions
diff --git a/redis_cluster.h b/redis_cluster.h
index 9bf0144e..a801fc51 100644
--- a/redis_cluster.h
+++ b/redis_cluster.h
@@ -59,8 +59,9 @@
c->flags->mode = ATOMIC; \
/* Simple 1-1 command -> response macro */
-#define CLUSTER_PROCESS_CMD(cmdname, resp_func) \
+#define CLUSTER_PROCESS_CMD(cmdname, resp_func, readcmd) \
redisCluster *c = GET_CONTEXT(); \
+ c->readonly = CLUSTER_IS_ATOMIC(c) && readcmd; \
char *cmd; int cmd_len; short slot; void *ctx=NULL; \
if(redis_##cmdname##_cmd(INTERNAL_FUNCTION_PARAM_PASSTHRU,c->flags, &cmd, \
&cmd_len, &slot, &ctx)==FAILURE) { \
@@ -78,8 +79,9 @@
resp_func(INTERNAL_FUNCTION_PARAM_PASSTHRU, c, ctx);
/* More generic processing, where only the keyword differs */
-#define CLUSTER_PROCESS_KW_CMD(kw, cmdfunc, resp_func) \
+#define CLUSTER_PROCESS_KW_CMD(kw, cmdfunc, resp_func, readcmd) \
redisCluster *c = GET_CONTEXT(); \
+ c->readonly = CLUSTER_IS_ATOMIC(c) && readcmd; \
char *cmd; int cmd_len; short slot; void *ctx=NULL; \
if(cmdfunc(INTERNAL_FUNCTION_PARAM_PASSTHRU, c->flags, kw, &cmd, &cmd_len,\
&slot,&ctx)==FAILURE) { \