Permalink
Browse files

BGREWRITEAOF now works with swapping on

  • Loading branch information...
1 parent 1b03836 commit e7546c639301968a011265b96ea6e7f22407960e @antirez committed Jan 6, 2010
Showing with 26 additions and 6 deletions.
  1. +20 −3 redis.c
  2. +6 −3 redis.conf
View
@@ -6527,9 +6527,20 @@ static int rewriteAppendOnlyFile(char *filename) {
/* Iterate this DB writing every entry */
while((de = dictNext(di)) != NULL) {
- robj *key = dictGetEntryKey(de);
- robj *o = dictGetEntryVal(de);
- time_t expiretime = getExpire(db,key);
+ robj *key, *o;
+ time_t expiretime;
+ int swapped;
+
+ key = dictGetEntryKey(de);
+ if (key->storage == REDIS_VM_MEMORY) {
+ o = dictGetEntryVal(de);
+ swapped = 0;
+ } else {
+ o = vmPreviewObject(key);
+ key = dupStringObject(key);
+ swapped = 1;
+ }
+ expiretime = getExpire(db,key);
/* Save the key and associated value */
if (o->type == REDIS_STRING) {
@@ -6597,6 +6608,12 @@ static int rewriteAppendOnlyFile(char *filename) {
if (fwriteBulk(fp,key) == 0) goto werr;
if (fwriteBulkLong(fp,expiretime) == 0) goto werr;
}
+ /* We created a few temp objects if the key->value pair
+ * was about a swapped out object. Free both. */
+ if (swapped) {
+ decrRefCount(key);
+ decrRefCount(o);
+ }
}
dictReleaseIterator(di);
}
View
@@ -49,9 +49,12 @@ databases 16
# after 900 sec (15 min) if at least 1 key changed
# after 300 sec (5 min) if at least 10 keys changed
# after 60 sec if at least 10000 keys changed
-save 900 1
-save 300 10
-save 60 10000
+#
+# Note: you can disable saving at all commenting all the "save" lines.
+
+#save 900 1
+#save 300 10
+#save 60 10000
# Compress string objects using LZF when dump .rdb databases?
# For default that's set to 'yes' as it's almost always a win.

0 comments on commit e7546c6

Please sign in to comment.