diff options
author | antirez <antirez@gmail.com> | 2009-12-11 18:45:25 +0100 |
---|---|---|
committer | antirez <antirez@gmail.com> | 2009-12-11 18:45:25 +0100 |
commit | b32627cdc10c2f3f6d08ea75b705b85d1de6b46d (patch) | |
tree | 7dfc6347e41b59decb20659b223e5fabb7c3e91d | |
parent | 5ad3c8c852de981482afb28a8c2659456b2a8b3b (diff) | |
download | redis-b32627cdc10c2f3f6d08ea75b705b85d1de6b46d.tar.gz |
some change to redis-sha1.rb utility to make it more robust against non-meaningful changes in the dataset
-rw-r--r-- | TODO | 2 | ||||
-rw-r--r-- | redis.c | 2 | ||||
-rw-r--r-- | utils/redis-sha1.rb | 22 |
3 files changed, 21 insertions, 5 deletions
@@ -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. +* Dont' safe empty lists / sets / zsets on disk with snapshotting. +* Remove keys when a list / set / zset reaches length of 0. DOCUMENTATION WISHLIST ====================== @@ -923,7 +923,7 @@ void backgroundRewriteDoneHandler(int statloc) { 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) { diff --git a/utils/redis-sha1.rb b/utils/redis-sha1.rb index b240e2cac..a50f5610a 100644 --- a/utils/redis-sha1.rb +++ b/utils/redis-sha1.rb @@ -16,17 +16,31 @@ def redisSha1(opts={}) sha1="" r = Redis.new(opts) r.keys('*').sort.each{|k| - sha1 = Digest::SHA1.hexdigest(sha1+k) 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.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" - 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" - 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 + # puts "#{k} => #{sha1}" if len != 0 } sha1 end |