Features

  • Text and binary protocol support
  • Asynchronous and Synchronous Transport Support
  • Consistent Hashing and Distribution
  • Flexible (and selectable) hashing and distribution methods
  • Selectable hashing algorithm to match keys
  • Tunable compression limits and parameters

Requirements

Download and Installation

The easiest way to download and install Cache::Memcached::libmemcached module is to use CPAN:

$ perl -MCPAN -e 'install Cache::Memcached::libmemcached'

Configuration

You must set the list of memcached servers to be used, either explicitly when the new object is created, or using the server_add() method to append a server to the existing configuration. 

For example: 

use Cache::Memcached::libmemcached;
my $memd = Cache::Memcached::libmemcached->new({
  servers => [ "192.168.0.2:11211", "192.168.0.3:11212" ],
});

Is equivalent to:

use Cache::Memcached::libmemcached;
my $memd = Cache::Memcached::libmemcached->new();
$memd->server_add("192.168.0.2:11211");
$memd->server_add("192.168.0.3:11212");

Storing/Retrieving Values

You can store values using the set() method: 

$memd->set("samplekey", "samplevalue");

If the value that you set is an object, the object will be serialized on store and deserialized on retrieval. 

To retrieve a value: 

my $val = $memd->get("samplekey");