]> git.saurik.com Git - redis.git/blobdiff - src/redis.c
Lua function creation on EVAL, basic Lua return type to Redis protocol convertion...
[redis.git] / src / redis.c
index 38e4ce527d55925ab669f675899d942cc04d8dd2..931eb1d72a5416cf47f32d926caa24f4bcab84d6 100644 (file)
@@ -102,8 +102,8 @@ struct redisCommand redisCommandTable[] = {
     {"ltrim",ltrimCommand,4,0,NULL,1,1,1,0,0},
     {"lrem",lremCommand,4,0,NULL,1,1,1,0,0},
     {"rpoplpush",rpoplpushCommand,3,REDIS_CMD_DENYOOM,NULL,1,2,1,0,0},
-    {"sadd",saddCommand,3,REDIS_CMD_DENYOOM,NULL,1,1,1,0,0},
-    {"srem",sremCommand,3,0,NULL,1,1,1,0,0},
+    {"sadd",saddCommand,-3,REDIS_CMD_DENYOOM,NULL,1,1,1,0,0},
+    {"srem",sremCommand,-3,0,NULL,1,1,1,0,0},
     {"smove",smoveCommand,4,0,NULL,1,2,1,0,0},
     {"sismember",sismemberCommand,3,0,NULL,1,1,1,0,0},
     {"scard",scardCommand,2,0,NULL,1,1,1,0,0},
@@ -138,7 +138,7 @@ struct redisCommand redisCommandTable[] = {
     {"hmset",hmsetCommand,-4,REDIS_CMD_DENYOOM,NULL,1,1,1,0,0},
     {"hmget",hmgetCommand,-3,0,NULL,1,1,1,0,0},
     {"hincrby",hincrbyCommand,4,REDIS_CMD_DENYOOM,NULL,1,1,1,0,0},
-    {"hdel",hdelCommand,3,0,NULL,1,1,1,0,0},
+    {"hdel",hdelCommand,-3,0,NULL,1,1,1,0,0},
     {"hlen",hlenCommand,2,0,NULL,1,1,1,0,0},
     {"hkeys",hkeysCommand,2,0,NULL,1,1,1,0,0},
     {"hvals",hvalsCommand,2,0,NULL,1,1,1,0,0},
@@ -192,7 +192,9 @@ struct redisCommand redisCommandTable[] = {
     {"restore",restoreCommand,4,0,NULL,0,0,0,0,0},
     {"migrate",migrateCommand,6,0,NULL,0,0,0,0,0},
     {"dump",dumpCommand,2,0,NULL,0,0,0,0,0},
-    {"object",objectCommand,-2,0,NULL,0,0,0,0,0}
+    {"object",objectCommand,-2,0,NULL,0,0,0,0,0},
+    {"client",clientCommand,-2,0,NULL,0,0,0,0,0},
+    {"eval",evalCommand,-3,0,NULL,0,0,0,0,0}
 };
 
 /*============================ Utility functions ============================ */
@@ -585,6 +587,10 @@ int serverCron(struct aeEventLoop *eventLoop, long long id, void *clientData) {
      */
     updateLRUClock();
 
+    /* Record the max memory used since the server was started. */
+    if (zmalloc_used_memory() > server.stat_peak_memory)
+        server.stat_peak_memory = zmalloc_used_memory();
+
     /* We received a SIGTERM, shutting down here in a safe way, as it is
      * not ok doing so inside the signal handler. */
     if (server.shutdown_asap) {
@@ -957,6 +963,7 @@ void initServer() {
     server.stat_starttime = time(NULL);
     server.stat_keyspace_misses = 0;
     server.stat_keyspace_hits = 0;
+    server.stat_peak_memory = 0;
     server.unixtime = time(NULL);
     aeCreateTimeEvent(server.el, 1, serverCron, NULL, NULL);
     if (server.ipfd > 0 && aeCreateFileEvent(server.el,server.ipfd,AE_READABLE,
@@ -975,6 +982,7 @@ void initServer() {
 
     if (server.ds_enabled) dsInit();
     if (server.cluster_enabled) clusterInit();
+    scriptingInit();
     srand(time(NULL)^getpid());
 }
 
@@ -1090,13 +1098,15 @@ int processCommand(redisClient *c) {
             addReplyError(c,"The cluster is down. Check with CLUSTER INFO for more information");
             return REDIS_OK;
         } else {
-            clusterNode *n = getNodeByQuery(c,cmd,c->argv,c->argc,&hashslot);
+            int ask;
+            clusterNode *n = getNodeByQuery(c,cmd,c->argv,c->argc,&hashslot,&ask);
             if (n == NULL) {
-                addReplyError(c,"Invalid cross-node request");
+                addReplyError(c,"Multi keys request invalid in cluster");
                 return REDIS_OK;
             } else if (n != server.cluster.myself) {
                 addReplySds(c,sdscatprintf(sdsempty(),
-                    "-MOVED %d %s:%d\r\n",hashslot,n->ip,n->port));
+                    "-%s %d %s:%d\r\n", ask ? "ASK" : "MOVED",
+                    hashslot,n->ip,n->port));
                 return REDIS_OK;
             }
         }
@@ -1240,7 +1250,6 @@ sds genRedisInfoString(char *section) {
     sds info = sdsempty();
     time_t uptime = time(NULL)-server.stat_starttime;
     int j, numcommands;
-    char hmem[64];
     struct rusage self_ru, c_ru;
     unsigned long lol, bib;
     int allsections = 0, defsections = 0;
@@ -1254,7 +1263,6 @@ sds genRedisInfoString(char *section) {
     getrusage(RUSAGE_SELF, &self_ru);
     getrusage(RUSAGE_CHILDREN, &c_ru);
     getClientsMaxBuffers(&lol,&bib);
-    bytesToHuman(hmem,zmalloc_used_memory());
 
     /* Server */
     if (allsections || defsections || !strcasecmp(section,"server")) {
@@ -1299,23 +1307,28 @@ sds genRedisInfoString(char *section) {
 
     /* Memory */
     if (allsections || defsections || !strcasecmp(section,"memory")) {
+        char hmem[64];
+        char peak_hmem[64];
+
+        bytesToHuman(hmem,zmalloc_used_memory());
+        bytesToHuman(peak_hmem,server.stat_peak_memory);
         if (sections++) info = sdscat(info,"\r\n");
         info = sdscatprintf(info,
             "# Memory\r\n"
             "used_memory:%zu\r\n"
             "used_memory_human:%s\r\n"
             "used_memory_rss:%zu\r\n"
+            "used_memory_peak:%zu\r\n"
+            "used_memory_peak_human:%s\r\n"
             "mem_fragmentation_ratio:%.2f\r\n"
-            "use_tcmalloc:%d\r\n",
+            "mem_allocator:%s\r\n",
             zmalloc_used_memory(),
             hmem,
             zmalloc_get_rss(),
+            server.stat_peak_memory,
+            peak_hmem,
             zmalloc_get_fragmentation_ratio(),
-    #ifdef USE_TCMALLOC
-            1
-    #else
-            0
-    #endif
+            REDIS_MALLOC
             );
     }