in reply to Cache::MemoryCache
You can use a two level cache.
#!/usr/bin/perl -w use Cache::MemoryCache; use Cache::FileCache; my $file_cache = new Cache::FileCache(); my $mem_cache = new Cache::MemoryCache(); my $customer = $mem_cache->get($ARGV[0]); if( not defined $customer ){ $customer = $file_cache->get($ARGV[0]); if( not defined $customer ){ print "setting cache\n"; $customer->{'email_address'} = 'foo@foo.com'; $customer->{'first_name'} = 'foo'; $customer->{'last_name'} = 'bar'; $customer->{'id'} = $ARGV[0]; $file_cache->set($ARGV[0], $customer, "10 minutes" ); } $mem_cache->set($ARGV[0], $customer, "10 minutes" ); }
Note: untested, and may contain logic errors.
|
|---|