Redis-Dump -


GPL
Linux
Ruby

软件简介

Redis-Dump
是一个将Redis数据导入/导出为json格式数据的小工具,目前还在Alpha版本,目前提供两个命令,将Redis数据层出成json的redis-
dump命令,以及将json文件导入到redis中的redis-load命令,喜欢尝鲜的同学可以试玩一下。

另外个人认为这也是一个适合新手的Redis数据结构学习工具,通过将Redis几种数据结构dump成json,可以让我们更直观的认识Redis数据结构及其操作。

下面是使用简介:

$ redis-dump
$ redis-dump -u 127.0.0.1:6371 > db_full.json
$ redis-dump -u 127.0.0.1:6371 -d 15 > db_db15.json

$ < db_full.json redis-load
$ < db_db15.json redis-load -d 15
# OR
$ cat db_full | redis-load
$ cat db_db15.json | redis-load -d 15

# You can specify the redis URI via an environment variable
$ export REDIS_URI=127.0.0.1:6371
$ redis-dump

层出的json数据格式如下,包括了db,key,ttl,数据的type,以及相应的数据

{"db":0,"key":"hashkey","ttl":-1,"type":"hash","value":{"field_a":"value_a","field_b":"value_b","field_c":"value_c"},"size":42}
{"db":0,"key":"listkey","ttl":-1,"type":"list","value":["value_0","value_1","value_2","value_0","value_1","value_2"],"size":42}
{"db":0,"key":"setkey","ttl":-1,"type":"set","value":["value_2","value_0","value_1","value_3"],"size":28}
{"db":0,"key":"zsetkey","ttl":-1,"type":"zset","value":[["value_0","100"],["value_1","100"],["value_2","200"],["value_3","300"],["value_4","400"]],"size":50}
{"db":0,"key":"stringkey","ttl":79,"type":"string","value":"stringvalue","size":11}

介绍内容来自:http://blog.nosqlfan.com/html/3632.html