]> git.saurik.com Git - redis.git/commitdiff
some change to redis-sha1.rb utility to make it more robust against non-meaningful...
authorantirez <antirez@gmail.com>
Fri, 11 Dec 2009 17:45:25 +0000 (18:45 +0100)
committerantirez <antirez@gmail.com>
Fri, 11 Dec 2009 17:45:25 +0000 (18:45 +0100)
TODO
redis.c
utils/redis-sha1.rb

diff --git a/TODO b/TODO
index 6ae0bac121dcc3626623b81e402633ac713e94d6..7d3974019d49b1ac206433aea5d0bda37f2e4b61 100644 (file)
--- a/TODO
+++ b/TODO
@@ -61,6 +61,8 @@ it's not a guarantee they'll ever get implemented ;)
 * zmalloc() should avoid to add a private header for archs where there is some other kind of libc-specific way to get the size of a malloced block. Already done for Mac OS X.
 * Read-only mode.
 * Pattern-matching replication.
 * zmalloc() should avoid to add a private header for archs where there is some other kind of libc-specific way to get the size of a malloced block. Already done for Mac OS X.
 * Read-only mode.
 * Pattern-matching replication.
+* Dont' safe empty lists / sets / zsets on disk with snapshotting.
+* Remove keys when a list / set / zset reaches length of 0.
 
 DOCUMENTATION WISHLIST
 ======================
 
 DOCUMENTATION WISHLIST
 ======================
diff --git a/redis.c b/redis.c
index db25135ac25235c0b790f709a249b3207050f54e..028563a237b5444488bffe5b433a663b46ec1224 100644 (file)
--- a/redis.c
+++ b/redis.c
@@ -923,7 +923,7 @@ void backgroundRewriteDoneHandler(int statloc) {
             close(fd);
             goto cleanup;
         }
             close(fd);
             goto cleanup;
         }
-        redisLog(REDIS_WARNING,"Parent diff flushed into the new append log file with success");
+        redisLog(REDIS_NOTICE,"Parent diff flushed into the new append log file with success (%lu bytes)",sdslen(server.bgrewritebuf));
         /* Now our work is to rename the temp file into the stable file. And
          * switch the file descriptor used by the server for append only. */
         if (rename(tmpfile,server.appendfilename) == -1) {
         /* Now our work is to rename the temp file into the stable file. And
          * switch the file descriptor used by the server for append only. */
         if (rename(tmpfile,server.appendfilename) == -1) {
index b240e2cac183a149e40568b02a2dfc1bb14767a4..a50f5610aa7bc7784261be767bc8076224862c59 100644 (file)
@@ -16,17 +16,31 @@ def redisSha1(opts={})
     sha1=""
     r = Redis.new(opts)
     r.keys('*').sort.each{|k|
     sha1=""
     r = Redis.new(opts)
     r.keys('*').sort.each{|k|
-        sha1 = Digest::SHA1.hexdigest(sha1+k)
         vtype = r.type?(k)
         if vtype == "string"
         vtype = r.type?(k)
         if vtype == "string"
+            len = 1
+            sha1 = Digest::SHA1.hexdigest(sha1+k)
             sha1 = Digest::SHA1.hexdigest(sha1+r.get(k))
         elsif vtype == "list"
             sha1 = Digest::SHA1.hexdigest(sha1+r.get(k))
         elsif vtype == "list"
-            sha1 = Digest::SHA1.hexdigest(sha1+r.list_range(k,0,-1).join("\x01"))
+            len = r.llen(k)
+            if len != 0
+                sha1 = Digest::SHA1.hexdigest(sha1+k)
+                sha1 = Digest::SHA1.hexdigest(sha1+r.list_range(k,0,-1).join("\x01"))
+            end
         elsif vtype == "set"
         elsif vtype == "set"
-            sha1 = Digest::SHA1.hexdigest(sha1+r.set_members(k).to_a.sort.join("\x02"))
+            len = r.scard(k)
+            if len != 0
+                sha1 = Digest::SHA1.hexdigest(sha1+k)
+                sha1 = Digest::SHA1.hexdigest(sha1+r.set_members(k).to_a.sort.join("\x02"))
+            end
         elsif vtype == "zset"
         elsif vtype == "zset"
-            sha1 = Digest::SHA1.hexdigest(sha1+r.zrange(k,0,-1).join("\x01"))
+            len = r.zcard(k)
+            if len != 0
+                sha1 = Digest::SHA1.hexdigest(sha1+k)
+                sha1 = Digest::SHA1.hexdigest(sha1+r.zrange(k,0,-1).join("\x01"))
+            end
         end
         end
+        # puts "#{k} => #{sha1}" if len != 0
     }
     sha1
 end
     }
     sha1
 end