Localmemcache is a library for C and Ruby that aims
to provide
an interface similar to memcached but for accessing local data instead of
remote data. It's based on mmap()'ed shared memory for maximum
speed.
Since version 0.3.0 it supports persistence, also making it a fast
alternative to GDBM, Berkeley DB, and Tokyo Cabinet.

Version 0.4.4: Bugfixes for OS X and Autorepair

Version 0.4.4 brings fixes for coredumps on OS X and bugs in the
autorepair (now also better covered by tests).
New methods: shm_status, has_key?
(Thanks to Max Schöfmann and Florian Dütsch for feedback/bug reports.)

Previous Releases

Version 0.4.3: Improving Iteration and bugfixes (2009-10-02)

Fixes by Paul Mineiro (thanks!):

iteration speedup: each_pair is now a lot faster when dealing with a
large dictionary. Eg: For 400k elements it's now about 14 times
faster.

fix for leak in local_memcache_free()

C API: Some C API functions were not yet covered by tests. This
has been fixed.

Version 0.4.2: Improving Append Performance (2009-08-10)

In 0.4.2 the :min_alloc_size parameter was introduced to help with use
cases that intend to use a hash table with growing values. This is
currently not handled well by the internal allocator as it will end up
with a large list of unusable free blocks. By setting the
:min_alloc_size parameter you help the allocator to plan better
ahead. (more)

Requirements

Note for OS X: OS X disqualifies as HFS+ doesn't
have sparse files and sem_timedwait() and sem_getvalue() aren't
supported as well.
Note for FreeBSD: It has been reported that localmemcache
sometimes hangs there, it is not yet clear what the problem is.

So, on my machine, using localmemcache 0.4.0 to store key-value
data on disk is about 10% slower than keeping them in memory in a
Ruby hash of strings. It's about 40% faster than Tokyo Cabinet
(which offers features similar to LocalMemCache).

Who uses Localmemcache?

Personifi use localmemcache to
serve billions of hits each month. Armin Roehrl: "we use
localmemcache because it solves one problem very well and we love it!"

Source code

Caveats

Localmemcache's .lmc files are not binary compatible across different
CPU architectures, they are essentially
memory mapped c structs

Because of the convenient auto repair feature after a lock timeout,
localmemcache is allergic to SIGSTOP (If you manage to SIGSTOP a process
while localmemcache is currently possessing a lock, that is)

Tips for backups

Note that you cannot copy localmemcache's .lmc files while other
processes are making changes to the data, this will likely result in a
corrupt backup. So you need to make sure that none of your processes are
writing during the time you do an backup. As for copying sparse files,
cp recognizes them automatically, with tar you need to use
the -S option.