高性能Ruby缓存系统 Localmemcache

jopen 12年前
     <p>Localmemcache 是一个高性能的基于 Unix/Linux mmap() 接口的 key-value 数据库,采用 Ruby 开发,同时也提供 C 语言的客户端接口。</p>    <p>安装方法:<code>gem install localmemcache</code></p>    <p>示例代码:</p>    <pre><code>require 'localmemcache' # 1. the memcached way # $lm = LocalMemCache.new :namespace => :viewcounters # 2. the GDBM way #$lm = LocalMemCache.new :filename => "./viewcounters.lmc" # 3. Using LocalMemCache::SharedObjectStorage $lm = LocalMemCache::SharedObjectStorage.new :filename =>      "./viewcounters.lmc" $lm[:foo] = 1 $lm[:foo] $lm.delete(:foo)</code></pre>    <p>性能:</p>    <p>在一台配置为<strong>Intel(R) Xeon(R) CPU E5205 @ 1.86GHz</strong> 的服务器上对下面几个系统进行性能比较:</p>    <p>Ruby 压力测试伪码:</p>    <pre><code>2_000_000.times {   index = rand(10000).to_s   $hash.set(index, index)   $hash.get(index) }</code></pre>    <pre>MemCache:              <strong>253,326.122</strong> ms GDBM:                   <strong>24,226.116</strong> ms Tokyo Cabinet:           <strong>9,092.707</strong> ms Localmemcache 0.4.0:     <strong>5,310.055</strong> ms Ruby Hash of Strings:    <strong>4,963.313</strong> ms</pre>    <p><strong>项目主页:</strong><a href="http://www.open-open.com/lib/view/home/1324813164593" target="_blank">http://www.open-open.com/lib/view/home/1324813164593</a></p>