]> git.saurik.com Git - redis.git/blobdiff - src/slowlog.c
Use less memory when emitting the protocol, by using more shared objects for commonly...
[redis.git] / src / slowlog.c
index a257a17bf7c2dd5d2006303b546e5901bab6f998..cfd66dc634d45dbc12bc9e1980fac40164374f25 100644 (file)
@@ -26,6 +26,7 @@ slowlogEntry *slowlogCreateEntry(robj **argv, int argc, long long duration) {
     }
     se->time = time(NULL);
     se->duration = duration;
     }
     se->time = time(NULL);
     se->duration = duration;
+    se->id = server.slowlog_entry_id++;
     return se;
 }
 
     return se;
 }
 
@@ -47,6 +48,7 @@ void slowlogFreeEntry(void *septr) {
  * at server startup. */
 void slowlogInit(void) {
     server.slowlog = listCreate();
  * at server startup. */
 void slowlogInit(void) {
     server.slowlog = listCreate();
+    server.slowlog_entry_id = 0;
     listSetFreeMethod(server.slowlog,slowlogFreeEntry);
 }
 
     listSetFreeMethod(server.slowlog,slowlogFreeEntry);
 }
 
@@ -55,7 +57,7 @@ void slowlogInit(void) {
  * configured max length. */
 void slowlogPushEntryIfNeeded(robj **argv, int argc, long long duration) {
     if (server.slowlog_log_slower_than < 0) return; /* Slowlog disabled */
  * configured max length. */
 void slowlogPushEntryIfNeeded(robj **argv, int argc, long long duration) {
     if (server.slowlog_log_slower_than < 0) return; /* Slowlog disabled */
-    if (duration > server.slowlog_log_slower_than)
+    if (duration >= server.slowlog_log_slower_than)
         listAddNodeHead(server.slowlog,slowlogCreateEntry(argv,argc,duration));
 
     /* Remove old entries if needed. */
         listAddNodeHead(server.slowlog,slowlogCreateEntry(argv,argc,duration));
 
     /* Remove old entries if needed. */
@@ -96,7 +98,8 @@ void slowlogCommand(redisClient *c) {
             int j;
 
             se = ln->value;
             int j;
 
             se = ln->value;
-            addReplyMultiBulkLen(c,3);
+            addReplyMultiBulkLen(c,4);
+            addReplyLongLong(c,se->id);
             addReplyLongLong(c,se->time);
             addReplyLongLong(c,se->duration);
             addReplyMultiBulkLen(c,se->argc);
             addReplyLongLong(c,se->time);
             addReplyLongLong(c,se->duration);
             addReplyMultiBulkLen(c,se->argc);