wiki:jazz/11-02-15

2011-02-15

memcached, PHP & Perl

~$ sudo apt-get install memcached php5-memcache libcache-memcached-perl
  • Memcached and Perl (PDF)
    use Cache::Memcached;
    #Connect
    my $cache = Cache::Memcached->new(servers => [ 10.0.0.1:11211,
    10.0.0.2:11211 ]);
    # Set some data - $data can be a ref, as long as Storable can nfreeze it
    $cache->set($key, $data, 3600); # 1 hour expiry
    # Get the data back
    my $x = $cache->get($key);
    # or get multiple pieces simultaneously
    my $hashref = $cache->get_multi($key1, $key2, $key3);
    
Last modified 14 years ago Last modified on Feb 16, 2011, 8:46:40 AM