How to cache simple arrays

Luc Levesque lucl2001 at
Sun Oct 29 17:05:50 UTC 2006

    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!";
            < Get from DB >
            # Set cache
            # Wasn't cached, so cache it!            $memd->set($HashKey, @Result);            $memd->disconnect_all();
-------------- next part --------------
An HTML attachment was scrubbed...

More information about the memcached mailing list