Boost logo

Boost Users :

Subject: [Boost-users] [Interprocess] Container of containers LRU
From: Matthieu Tourne (matthieu.tourne_at_[hidden])
Date: 2011-05-23 13:49:05


Hi,

I'm looking into implementing an object cache available from multiple
processes, I naturally found the boost::interprocess library mostly adapted
for this.
My problem is how to implement a cache eviction mechanism (LRU or other)
when shared memory segment has been filled up.

My problem gets worse, when I start using containers of containers, as
described here :
http://www.boost.org/doc/libs/1_46_1/doc/html/interprocess/allocators_containers.html#interprocess.allocators_containers.containers_explained.containers_of_containers

So I have that allocator that I use everywhere, like in the example :

typedef managed_shared_memory::segment_manager
 segment_manager_t;
typedef allocator<void, segment_manager_t>
void_allocator;

I use it to create a boost::interprocess::map of objects, which in turn can
contain a boost::interprocess::map of strings in shared memory as well.

So to recap, I have an map of Object like an "object store" and each Object
can contain a "dictionary" (map of strings) of unknown size, all of those
living in a shared memory segment.

My problem, is that shared memory segments are of a given size and any of
the allocate() operation that the allocator is going to perform (when adding
a new Object, or a new element in a dictionary)
can throw a boost::interprocess::bad_alloc exception.

So I'm wondering if there is a more suited library to do persistent caching
of objects between processes, with a way to automatically evicts "old cache"
from the memory.
Or if there is a way to implement my own allocator that would be more aware
of my design, and would deallocate one of the Objects and the associated
dictionary if an allocate() were to fail.

I've been scratching my head for a little while now, and any suggestions or
example of code would be really appreciated!

Thank you,

Matthieu.



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net