# Localmemcache-0.0.1, efficiently sharing a Hashtable on a local Unix machine

**URL:** <https://www.ruby-forum.com/t/localmemcache-0-0-1-efficiently-sharing-a-hashtable-on-a-local-unix-machine/162247>\
**Category:** Ruby\
**Created:** [March 7, 2009, 1:25pm UTC](https://www.ruby-forum.com/t/localmemcache-0-0-1-efficiently-sharing-a-hashtable-on-a-local-unix-machine/162247 "2009-03-07T13:25:37Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sven\_CSKoehler](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/3be4f8/32.png) [@Sven\_CSKoehler](https://www.ruby-forum.com/u/Sven_CSKoehler)\
**Post date:** [March 7, 2009, 1:25pm UTC](https://www.ruby-forum.com/t/localmemcache-0-0-1-efficiently-sharing-a-hashtable-on-a-local-unix-machine/162247/1 "2009-03-07T13:25:37Z")

</div>

Hi,

today I am releasing the very first version of localmemcache (version  
0.0.1).  
Localmemcache is a library written in C that offers efficient sharing of  
a  
hashtable between processes on a local Unix machine by taking advantage  
of  
shared memory. Its Ruby binding aims to be similar to that of the  
MemCache  
Ruby bindings.

- [http://localmemcache.rubyforge.org/](http://localmemcache.rubyforge.org/)

# EXAMPLE

require ‘localmemcache’  
$lm = LocalMemCache.new :namespace =\> “viewcounters”  
$lm[:foo] = 1  
$lm[:foo]  
$lm.delete(:foo)

# PERFORMANCE

Here’s a quick speed comparison, made on an  
Intel(R) Xeon(R) CPU E5205 @ 1.86GHz:

Benchmark pseudo code:

2\_000\_000.times {  
index = rand(10000).to\_s  
$hash.set(index, index)  
$hash.get(index)  
}

MemCache: 253326.122 ms  
LocalMemCache: 6055.552 ms  
Ruby’s Hash: 4963.313 ms

So in this example localmemcache is about 40 times faster than using  
memcache  
locally, and about 20% slower than Ruby’s hash.

# INSTALL

# gem install localmemcache

# CONTACT

Please contact me with bugs, suggestions and patches at: schween + snafu

# de

# LINKS

Localmemcache: [http://localmemcache.rubyforge.org/](http://localmemcache.rubyforge.org/)  
Rubyforge project: [http://localmemcache.rubyforge.org/](http://localmemcache.rubyforge.org/)

Source code is hosted on github: [GitHub - sck/localmemcache: mmap -\> lmc\_valloc -\> hashtable. BAM database](http://github.com/sck/localmemcache/)

Best,

Sven C. Koehler

localmemcache-0.0.1.gem 251971dd68451656d756b8bd1abe5879
