Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Reduce useless complexity in AOF generation.

The AOF file generated by `RDB::Dumpers::AOF` is now identical to the output
of Redis 2.4 (with `variadic: false`) and Redis 2.6 (with `variadic: true`).
  • Loading branch information...
commit cad13c012e45077c644a9d7f271303f91c61eab2 1 parent 67c53eb
@nrk authored
Showing with 5 additions and 6 deletions.
  1. +5 −6 lib/rdb/dumpers/aof.rb
View
11 lib/rdb/dumpers/aof.rb
@@ -73,8 +73,7 @@ def end_hash(key, state)
def handle(command, state, key, *arguments)
if variadic?
- state.info[:buffer].push(*arguments)
- state.info[:queued] += arguments.length
+ state.info[:buffer].push(arguments)
flush(command, state) if buffer_full?(state)
else
self << serialize_command(command, [key, *arguments])
@@ -83,7 +82,7 @@ def handle(command, state, key, *arguments)
def flush(command, state)
if buffer_some?(state)
- self << serialize_command(command, state.info[:buffer])
+ self << serialize_command(command, [state.key] + state.info[:buffer].flatten)
reset_buffer(state)
end
end
@@ -98,15 +97,15 @@ def variadic?
end
def reset_buffer(state)
- state.info.merge!({ buffer: [state.key], queued: 0 })
+ state.info[:buffer] = [];
end
def buffer_some?(state)
- (state.info[:queued] || 0) > 0
+ state.info[:buffer].length > 0
end
def buffer_full?(state)
- (state.info[:queued] || 0) == REDIS_AOF_REWRITE_ITEMS_PER_CMD
+ state.info[:buffer].length == REDIS_AOF_REWRITE_ITEMS_PER_CMD
end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.