Redis数据导入/导出为JSON的小工具 - Redis-Dump
fmms
13年前
<p>Redis-Dump 是一个将<a href="http://www.open-open.com/lib/view/open1322720835515.html">Redis</a>数据导入/导出为<span>json</span>格式数据的小工具,目前还在Alpha版本,目前提供两个命令,将Redis数据层出成json的<span>redis-dump</span>命令,以及将json文件导入到redis中的<span>redis-load</span>命令,喜欢尝鲜的同学可以试玩一下。</p> <p>另外个人认为这也是一个适合新手的Redis数据结构学习工具,通过将Redis几种数据结构dump成json,可以让我们更直观的认识Redis数据结构及其操作。</p> <p>下面是使用示例:</p> <pre class="brush:ruby; toolbar: true; auto-links: false;">$ 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</pre>导出的json数据格式如下,包括了db,key,ttl,数据的type,以及相应的数据 <pre class="brush:javascript; toolbar: true; auto-links: false;">{"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}</pre> <div id="p_fullcontent" class="detail"> <p><span class="hilite1"><a href="http://www.open-open.com/lib/view/open1322720835515.html" target="_blank"><strong>Redis</strong> </a>是</span>一个高性能的key-value数据库。 <span class="hilite1">redis</span>的出现,很大程度补偿了<a href="http://www.open-open.com/lib/view/open1322706513327.html">memcached</a>这类keyvalue存储的不足,在部 分场合可以对关系数据库起到很好的补充作用。它提供了Python,Ruby,Erlang,PHP客户端,使用很方便。</p> <p>性能测试结果:</p> <p>SET操作每秒钟 110000 次,GET操作每秒钟 81000 次,服务器配置如下:</p> <p><strong>Linux 2.6</strong>, <strong>Xeon X3320 2.5Ghz</strong>.</p> <p>stackoverflow 网站使用 Redis 做为缓存服务器。</p> </div> 介绍内容来自:http://blog.nosqlfan.com/html/3632.html <br /> <br /> <p><strong>项目主页:</strong><a href="http://www.open-open.com/lib/view/home/1326068541890" target="_blank">http://www.open-open.com/lib/view/home/1326068541890</a></p> <p></p>