# Basic methods are like in Cache::Memcached, but with additional cb => sub { ... };
# first argument to cb is return value, second is the error(s)
$memd->set( key => $value, cb => sub {
shift or warn "Set failed: @_"
} );
$memd->get( 'key', cb => sub {
my ($value,$err) = shift;
$err and return warn "Get failed: @_";
warn "Value for key is $value";
} );
$memd->mget( [ 'key1', 'key2' ], cb => sub {
my ($values,$err) = shift;
$err and return warn "Get failed: @_";
warn "Value for key1 is $values->{key1} and value for key2 is $values->{key2}"
} );
# Additionally there is rget (see memcachedb-1.2.1-beta)
$memd->rget( 'fromkey', 'tokey', cb => sub {
my ($value,$err) = shift;
$err and warn "Get failed: @_";
} );
METHODS
new %args
Currently supported options:
servers =item namespace =item debug =item cv =item compress_threshold
=item compress_enable =item timeout =item noreply
If true, additional connection will established for noreply
commands. Beware, feature is under development and may be unstable
set_servers
Setup server list
connect
Establish connection to all servers and invoke event C<connected>, when ready
set( $key, $value, [cv => $cv], [ expire => $expire ], cb => $cb->( $rc, $err ) )
Unconditionally sets a key to a given value in the memcache.
$rc is
'1' Successfully stored
'0' Item was not stored
undef
Error happens, see $err
add( $key, $value, [cv => $cv], [ expire => $expire ], cb => $cb->( $rc, $err ) )
Like "set", but only stores in memcache if the key doesn't already
exist.
replace( $key, $value, [cv => $cv], [ expire => $expire ], cb => $cb->( $rc, $err ) )
Like "set", but only stores in memcache if the key already exists. The
opposite of add.
append( $key, $value, [cv => $cv], [ expire => $expire ], cb => $cb->( $rc, $err ) )
Append the $value to the current value on the server under the $key.
append command first appeared in memcached 1.2.4.
prepend( $key, $value, [cv => $cv], [ expire => $expire ], cb => $cb->( $rc, $err ) )
Prepend the $value to the current value on the server under the $key.
prepend command first appeared in memcached 1.2.4.
get( $key, [cv => $cv], [ expire => $expire ], cb => $cb->( $rc, $err ) )
Retrieve the value for a $key. $key should be a scalar
gets( $keys : ARRAYREF, [cv => $cv], [ expire => $expire ], cb => $cb->( $rc, $err ) )
Retrieve the value and its CAS for a $key. $key should be a scalar.
NOT IMPLEMENTED YET
delete( $key, [cv => $cv], [ noreply => 1 ], cb => $cb->( $rc, $err ) )
Delete $key and its value from the cache.
If "noreply" is true, cb doesn't required
del
Alias for "delete"
remove
Alias for "delete"
incr( $key, $increment, [cv => $cv], [ noreply => 1 ], cb => $cb->( $rc, $err ) )
Increment the value for the $key by $delta. Starting with memcached
1.3.3 $key should be set to a number or the command will fail. Note that
the server doesn't check for overflow.
If "noreply" is true, cb doesn't required, and if passed, simply called
with rc = 1
Similar to DBI, zero is returned as "0E0", and evaluates to true in a
boolean context.