]> git.saurik.com Git - redis.git/commitdiff
INFO fixed, MGET implemented, redis-cli implements INFO/MGET
authorantirez <antirez@gmail.com>
Sun, 22 Mar 2009 13:54:14 +0000 (14:54 +0100)
committerantirez <antirez@gmail.com>
Sun, 22 Mar 2009 13:54:14 +0000 (14:54 +0100)
redis-cli.c
redis.c

index 5444ac00ce3d31ba7471ae1d08a806ea69579746..f6bf739b3696e6f1caa02b03074321c740e0bf68 100644 (file)
@@ -103,7 +103,8 @@ static struct redisCommand cmdTable[] = {
     {"flushdb",1,REDIS_CMD_INLINE|REDIS_CMD_RETCODEREPLY},
     {"flushall",1,REDIS_CMD_INLINE|REDIS_CMD_RETCODEREPLY},
     {"sort",-2,REDIS_CMD_INLINE|REDIS_CMD_MULTIBULKREPLY},
-    {"version",1,REDIS_CMD_INLINE|REDIS_CMD_SINGLELINEREPLY},
+    {"info",1,REDIS_CMD_INLINE|REDIS_CMD_BULKREPLY},
+    {"mget",-2,REDIS_CMD_INLINE|REDIS_CMD_MULTIBULKREPLY},
     {NULL,0,0}
 };
 
diff --git a/redis.c b/redis.c
index 7c2b9a40042351ec75138e226998f486a55efc0a..04504eec201b01c12d171d589701b29d4dbce230 100644 (file)
--- a/redis.c
+++ b/redis.c
@@ -281,6 +281,7 @@ static void flushallCommand(redisClient *c);
 static void sortCommand(redisClient *c);
 static void lremCommand(redisClient *c);
 static void infoCommand(redisClient *c);
+static void mgetCommand(redisClient *c);
 
 /*================================= Globals ================================= */
 
@@ -294,6 +295,7 @@ static struct redisCommand cmdTable[] = {
     {"exists",existsCommand,2,REDIS_CMD_INLINE},
     {"incr",incrCommand,2,REDIS_CMD_INLINE},
     {"decr",decrCommand,2,REDIS_CMD_INLINE},
+    {"mget",mgetCommand,-2,REDIS_CMD_INLINE},
     {"rpush",rpushCommand,3,REDIS_CMD_BULK},
     {"lpush",lpushCommand,3,REDIS_CMD_BULK},
     {"rpop",rpopCommand,2,REDIS_CMD_INLINE},
@@ -1696,6 +1698,29 @@ static void getCommand(redisClient *c) {
     }
 }
 
+static void mgetCommand(redisClient *c) {
+    dictEntry *de;
+    int j;
+  
+    addReplySds(c,sdscatprintf(sdsempty(),"%d\r\n",c->argc-1));
+    for (j = 1; j < c->argc; j++) {
+        de = dictFind(c->dict,c->argv[j]);
+        if (de == NULL) {
+            addReply(c,shared.minus1);
+        } else {
+            robj *o = dictGetEntryVal(de);
+            
+            if (o->type != REDIS_STRING) {
+                addReply(c,shared.minus1);
+            } else {
+                addReplySds(c,sdscatprintf(sdsempty(),"%d\r\n",(int)sdslen(o->ptr)));
+                addReply(c,o);
+                addReply(c,shared.crlf);
+            }
+        }
+    }
+}
+
 static void incrDecrCommand(redisClient *c, int incr) {
     dictEntry *de;
     long long value;
@@ -2790,6 +2815,7 @@ static void infoCommand(redisClient *c) {
     );
     addReplySds(c,sdscatprintf(sdsempty(),"%d\r\n",sdslen(info)));
     addReplySds(c,info);
+    addReply(c,shared.crlf);
 }
 
 /* =============================== Replication  ============================= */