NoSQL数据库 tstdb新版发布:支持前缀搜素和范围搜索

openkk 13年前
     <a href="http://www.open-open.com/lib/view/open1322727404765.html" target="_blank">tstdb</a>是一种基于日志重放机制的memcached兼容的key-value数据库,可用于需要缓存数据落地的一些场合。    <h2 style="background-image:none;border-right-width:0px;padding-left:0px;max-width:700px;border-top-width:0px;border-bottom-width:0px;font-size:large;border-left-width:0px;background-origin:initial;background-clip:initial;"><span style="line-height:25px;font-family:Arial, sans-serif, Helvetica, Tahoma;font-size:medium;font-weight:normal;">它兼容memcached的客户端(支持get,set和delete命令),支持value过期设置。读写性能与memcached接近。日志重放速度很快,作者测试时一亿数据的reloading(key:10bytes ,value: 20 bytes)只需要2分钟,内存占用2.1G。<br /> <br /> </span></h2>    <p>这个版本的主要改进包括:</p>    <p>1. 加入了prefix search和range query的支持<br /> 2. 更好低兼容memcached,加入了incr/derc/gets/cas操作<br /> 3. 改进了服务器的buffer管理,更加稳定<br /> 4. 改进了数据持久化机制,除了日志重放外还加上了磁盘镜像reload功能,使得服务重启时数据加载更快<br /> 5. 支持pipeline请求,支持noreply的异步set操作</p>    <p>目前,您可以使用任意的memcached客户端来访问tstdb。<br /> 如果您需要使用prefix search等功能的话,目前只有一个python客户端pytst可用。不过,很容易扩展到其他语言。</p>    <p>安装说明:<a href="/misc/goto?guid=4958331501268302367">http://code.google.com/p/tstdb/wiki/TSTDBV2</a></p>    <p> </p>    <h2 style="background-image:none;border-right-width:0px;padding-left:0px;max-width:700px;border-top-width:0px;border-bottom-width:0px;font-size:large;border-left-width:0px;background-origin:initial;background-clip:initial;">Usage demo</h2>    <p style="line-height:1.25em;max-width:64em;"> </p>    <pre style="padding-bottom:0.5em;overflow-x:auto;overflow-y:auto;background-color:#eeeeee;padding-left:0.5em;padding-right:0.5em;font-family:Monaco, 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Lucida Console', monospace;max-width:70em;font-size:12px;padding-top:0.5em;" class="prettyprint"><span style="color:#000088;" class="kwd">import</span><span style="color:#000000;" class="pln"> pytst  tst </span><span style="color:#666600;" class="pun">=</span><span style="color:#000000;" class="pln"> pytst</span><span style="color:#666600;" class="pun">.</span><span style="color:#660066;" class="typ">TSTClient</span><span style="color:#666600;" class="pun">(</span><span style="color:#000000;" class="pln">host</span><span style="color:#666600;" class="pun">=</span><span style="color:#008800;" class="str">'localhost'</span><span style="color:#666600;" class="pun">,</span><span style="color:#000000;" class="pln">port</span><span style="color:#666600;" class="pun">=</span><span style="color:#006666;" class="lit">8402</span><span style="color:#666600;" class="pun">)</span><span style="color:#000000;" class="pln"> tst</span><span style="color:#666600;" class="pun">.</span><span style="color:#000088;" class="kwd">set</span><span style="color:#666600;" class="pun">(</span><span style="color:#008800;" class="str">"some_key"</span><span style="color:#666600;" class="pun">,</span><span style="color:#000000;" class="pln"> </span><span style="color:#008800;" class="str">"Some value"</span><span style="color:#666600;" class="pun">)</span><span style="color:#000000;" class="pln"> value </span><span style="color:#666600;" class="pun">=</span><span style="color:#000000;" class="pln"> tst</span><span style="color:#666600;" class="pun">.</span><span style="color:#000088;" class="kwd">get</span><span style="color:#666600;" class="pun">(</span><span style="color:#008800;" class="str">"some_key"</span><span style="color:#666600;" class="pun">)</span><span style="color:#000000;" class="pln"> </span><span style="color:#000088;" class="kwd">print</span><span style="color:#000000;" class="pln"> value    tst</span><span style="color:#666600;" class="pun">.</span><span style="color:#000088;" class="kwd">set</span><span style="color:#666600;" class="pun">(</span><span style="color:#008800;" class="str">"another_key"</span><span style="color:#666600;" class="pun">,</span><span style="color:#000000;" class="pln"> </span><span style="color:#006666;" class="lit">3</span><span style="color:#666600;" class="pun">)</span><span style="color:#000000;" class="pln"> tst</span><span style="color:#666600;" class="pun">.</span><span style="color:#000088;" class="kwd">delete</span><span style="color:#666600;" class="pun">(</span><span style="color:#008800;" class="str">"another_key"</span><span style="color:#666600;" class="pun">)</span><span style="color:#000000;" class="pln"> tst</span><span style="color:#666600;" class="pun">.</span><span style="color:#000088;" class="kwd">set</span><span style="color:#666600;" class="pun">(</span><span style="color:#008800;" class="str">"key"</span><span style="color:#666600;" class="pun">,</span><span style="color:#000000;" class="pln"> </span><span style="color:#008800;" class="str">"1"</span><span style="color:#666600;" class="pun">)</span><span style="color:#000000;" class="pln">   tst</span><span style="color:#666600;" class="pun">.</span><span style="color:#000000;" class="pln">incr</span><span style="color:#666600;" class="pun">(</span><span style="color:#008800;" class="str">"key"</span><span style="color:#666600;" class="pun">)</span><span style="color:#000000;" class="pln"> tst</span><span style="color:#666600;" class="pun">.</span><span style="color:#000000;" class="pln">decr</span><span style="color:#666600;" class="pun">(</span><span style="color:#008800;" class="str">"key"</span><span style="color:#666600;" class="pun">)</span><span style="color:#000000;" class="pln"> tst</span><span style="color:#666600;" class="pun">.</span><span style="color:#000088;" class="kwd">set</span><span style="color:#666600;" class="pun">(</span><span style="color:#008800;" class="str">'haha/1'</span><span style="color:#666600;" class="pun">,</span><span style="color:#006666;" class="lit">123</span><span style="color:#666600;" class="pun">)</span><span style="color:#000000;" class="pln"> tst</span><span style="color:#666600;" class="pun">.</span><span style="color:#000088;" class="kwd">set</span><span style="color:#666600;" class="pun">(</span><span style="color:#008800;" class="str">'haha/2'</span><span style="color:#666600;" class="pun">,</span><span style="color:#006666;" class="lit">456</span><span style="color:#666600;" class="pun">)</span><span style="color:#000000;" class="pln"> tst</span><span style="color:#666600;" class="pun">.</span><span style="color:#000088;" class="kwd">set</span><span style="color:#666600;" class="pun">(</span><span style="color:#008800;" class="str">'haha/5'</span><span style="color:#666600;" class="pun">,</span><span style="color:#008800;" class="str">'xyz'</span><span style="color:#666600;" class="pun">)</span><span style="color:#000000;" class="pln"> </span><span style="color:#000088;" class="kwd">print</span><span style="color:#000000;" class="pln"> tst</span><span style="color:#666600;" class="pun">.</span><span style="color:#000000;" class="pln">prefix</span><span style="color:#666600;" class="pun">(</span><span style="color:#008800;" class="str">'haha'</span><span style="color:#666600;" class="pun">)</span><span style="color:#000000;" class="pln"> </span><span style="color:#000088;" class="kwd">print</span><span style="color:#000000;" class="pln"> tst</span><span style="color:#666600;" class="pun">.</span><span style="color:#000000;" class="pln">less</span><span style="color:#666600;" class="pun">(</span><span style="color:#008800;" class="str">'haha/2'</span><span style="color:#666600;" class="pun">)</span><span style="color:#000000;" class="pln"> </span><span style="color:#000088;" class="kwd">print</span><span style="color:#000000;" class="pln"> tst</span><span style="color:#666600;" class="pun">.</span><span style="color:#000000;" class="pln">greater</span><span style="color:#666600;" class="pun">(</span><span style="color:#008800;" class="str">'haha/2'</span><span style="color:#666600;" class="pun">)</span></pre>    <p style="line-height:1.25em;max-width:64em;">output will be</p>    <pre style="padding-bottom:0.5em;overflow-x:auto;overflow-y:auto;background-color:#eeeeee;padding-left:0.5em;padding-right:0.5em;font-family:Monaco, 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Lucida Console', monospace;max-width:70em;font-size:12px;padding-top:0.5em;" class="prettyprint"><span style="color:#660066;" class="typ">Some</span><span style="color:#000000;" class="pln"> value</span><span style="color:#666600;" class="pun">[</span><span style="color:#008800;" class="str">'haha/1'</span><span style="color:#666600;" class="pun">,</span><span style="color:#000000;" class="pln"> </span><span style="color:#008800;" class="str">'haha/2'</span><span style="color:#666600;" class="pun">,</span><span style="color:#000000;" class="pln"> </span><span style="color:#008800;" class="str">'haha/5'</span><span style="color:#666600;" class="pun">]</span><span style="color:#000000;" class="pln"> </span><span style="color:#666600;" class="pun">[</span><span style="color:#008800;" class="str">'haha/2'</span><span style="color:#666600;" class="pun">,</span><span style="color:#000000;" class="pln"> </span><span style="color:#008800;" class="str">'haha/1'</span><span style="color:#666600;" class="pun">]</span><span style="color:#000000;" class="pln"> </span><span style="color:#666600;" class="pun">[</span><span style="color:#008800;" class="str">'haha/2'</span><span style="color:#666600;" class="pun">,</span><span style="color:#000000;" class="pln"> </span><span style="color:#008800;" class="str">'haha/5'</span><span style="color:#666600;" class="pun">,</span><span style="color:#000000;" class="pln"> </span><span style="color:#008800;" class="str">'key'</span><span style="color:#666600;" class="pun">,</span><span style="color:#000000;" class="pln"> </span><span style="color:#008800;" class="str">'some_key'</span><span style="color:#666600;" class="pun">]</span></pre>    <p style="text-indent:0em;" class="ProjectOfNews"></p>