summaryrefslogtreecommitdiff
path: root/src/multi.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/multi.c')
-rw-r--r--src/multi.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/multi.c b/src/multi.c
index 7000c4841..833ff7e0a 100644
--- a/src/multi.c
+++ b/src/multi.c
@@ -35,6 +35,8 @@
void initClientMultiState(redisClient *c) {
c->mstate.commands = NULL;
c->mstate.count = 0;
+ c->mstate.minreplicas = 0;
+ c->mstate.minreplicas_timeout = 0;
}
/* Release all the resources associated with MULTI/EXEC state */
@@ -321,3 +323,30 @@ void unwatchCommand(redisClient *c) {
c->flags &= (~REDIS_DIRTY_CAS);
addReply(c,shared.ok);
}
+
+/* ------------------------- MINREPLICAS implementation --------------------- */
+
+/* MINREPLICAS <count> <timeout> */
+void minreplicasCommand(redisClient *c) {
+ long timeout, minreplicas;
+
+ if (!(c->flags & REDIS_MULTI)) {
+ addReplyError(c,"MINREPLICAS without MULTI");
+ return;
+ }
+ if (getLongFromObjectOrReply(c,object,&minreplicas,
+ "number of replicas is not an integer or out of range") != REDIS_OK)
+ return REDIS_ERR;
+
+ if (getLongFromObjectOrReply(c,object,&timeout,
+ "timeout is not an integer or out of range") != REDIS_OK)
+ return REDIS_ERR;
+
+ /* Force sane values. */
+ if (timeout < 0) timeout = 0;
+ if (minreplicas < 0) minreplicas = 0;
+
+ c->mstate.minreplicas = minreplicas;
+ c->mstate.minreplicas_timeout = timeout;
+ addReply(c,shared.ok);
+}