in reply to Re: Re: Cache::MemoryCache
in thread Cache::MemoryCache

maybe, just maybe you can use Cache::SharedMemoryCache

have one program that that stays running to hold the cache in memory while other programs come and go.

# holdcache.pl use Cache::SharedMemoryCache; my %cache_options_= ( 'namespace' => 'MyNamespace', ); my $c = Cache::SharedMemoryCache->new( \%cache_options ) or die( "Couldn't instantiate SharedMemoryCache" ); while (1) { sleep 300; } __END__

should do to keep the cache open.

$ perl holdcache.pl & $ perl -e 'use Cache::SharedMemoryCache;$c=Cache::SharedMemoryCache->n +ew({namespace=>"MyNamespace"}) or die;$c->set("foo",1);' $ perl -e 'use Cache::SharedMemoryCache;$c=Cache::SharedMemoryCache->n +ew({namespace=>"MyNamespace"}) or die;$x=$c->get("foo");print $x,$/' 1

presto!

Replies are listed 'Best First'.
Re: Re: Re: Re: Cache::MemoryCache
by perrin (Chancellor) on Jul 19, 2003 at 20:58 UTC
    I recommend you use Cache::FileCache instead of Cache::SharedMemoryCache. The file cache is much faster. If you want to go even faster, Cache::Mmap is a good choice.