It's a good effort, but it is not the right approach IMHO.
Redis is very good at producing point-in-time snapshots via RDB files, so I think the right thing to do is to create a tool, or add this feature to redis-cli, so that it is able to translate RDB files into JSON and the other way around.<p>Also I think that a "generic" JSON is not a good idea, since a single JSON value can be a multi million elements list or alike. The best thing to do is to create a JSON that is also specifically conceived to be both valid but to also have a single element per line, so that can be parsed much faster and with minimal state without a real JSON parser if needed.
<p><pre><code> def dump filter=nil
filter ||= '*'
entries = []
each_database do |redis|
chunk_entries = []
dump_keys = redis.keys(filter)
. . .
</code></pre>
<a href="http://redis.io/commands/keys" rel="nofollow">http://redis.io/commands/keys</a><p><i>Warning: consider KEYS as a command that should only be used in production environments with extreme care. It may ruin performance when it is executed against large databases. This command is intended for debugging and special operations, such as changing your keyspace layout. Don't use KEYS in your regular application code.</i>