NAME
Cache::Memcached::LibMemcached - Perl Interface to libmemcached
SYNOPSIS
use Cache::Memcached::LibMemcached;
my $memd = Cache::Memcached::LibMemcached->new({
serves => [ "10.0.0.15:11211", "10.0.0.15:11212", "/var/sock/memcached" ],
compress_threshold => 10_000
});
$memd->set("my_key", "Some value");
$memd->set("object_key", { 'complex' => [ "object", 2, 4 ]});
$val = $memd->get("my_key");
$val = $memd->get("object_key");
if ($val) { print $val->{complex}->[2] }
$memd->incr("key");
$memd->decr("key");
$memd->incr("key", 2);
$memd->delete("key");
$memd->remove("key"); # Alias to delete
my $hashref = $memd->get_multi(@keys);
DESCRIPTION
This is the Perl Interface to libmemcached, a C library to interface with memcached.
There's also a Memcached::libmemcached available on googlecode, but the intent of Cache::Memcached::LibMemcached is to provide users with consistent API as Cache::Memcached.
METHODS
new
Takes on parameter, a hashref of options.
set_servers
Sets the server list. Note that currently you should not expect this to replace the server list that Cache::Memcached::LibMemcached works -- instead it ADDS to the list. Normally you shouldn't call this method directly, because it's called by new().
This behavior *may* change in later releases.
get
my $val = $memd->get($key);
Retrieves a key from the memcached. Returns the value (automatically thawed with Storable, if necessary) or undef.
Currently the arrayref form of $key is NOT supported. Perhaps in the future.
get_multi
my $hashref = $memd->get_multi(@keys);
Retrieves multiple keys from the memcache doing just one query. Returns a hashref of key/value pairs that were available.
set
$memd->set($key, $value[, $expires]);
Unconditionally sets a key to a given value in the memcache. Returns true if it was stored successfully.
Currently the arrayref form of $key is NOT supported. Perhaps in the future.
incr
decr
my $newval = $memd->incr($key);
my $newval = $memd->decr($key);
my $newval = $memd->incr($key, $offset);
my $newval = $memd->decr($key, $offset);
Atomically increments or decrements the specified the integer value specified by $key. Returns undef if the key doesn't exist on the server.
delete
remove
$memd->delete($key);
Deletes a key.
XXX - The behavior when second argument is specified may differ from Cache::Memcached -- this hasn't been very well tested. Patches welcome!
AUTHOR
Copyright (c) 2008 Daisuke Maki <daisuke@endeworks.jp>
LICENSE
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
See http://www.perl.com/perl/misc/Artistic.html