How to cache simple arrays
Luc Levesque
lucl2001 at hotmail.com
Sun Oct 29 17:05:50 UTC 2006
Hello,
I have setup memcached and it works great for getting / setting simple strings using the Perl API. The problem I have is when I try to SET / GET arrays ( ie: @Array ).
Here is the code I tried, this works fine for $String but with @CachedValue it doesn't work. I assume I'm not referencing the array correctly... any ideas?
my $memd = new Cache::Memcached { 'servers' => [ "localhost:1111" ], };
use Digest::SHA1 qw(sha1 sha1_hex sha1_base64); my $HashKey = sha1_hex("$statement");
# Get a value - will fail the first time as it has not been set. my @CachedValue = $memd->get( $HashKey );
if ( @CachedValue )
{
print "Got it!";
exit;
}
else
{
< Get from DB >
# Set cache
# Wasn't cached, so cache it! $memd->set($HashKey, @Result); $memd->disconnect_all();
}
Luc
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.danga.com/pipermail/memcached/attachments/20061029/9f67f9e5/attachment.html
More information about the memcached
mailing list