NAME

Cache::Memcached::Async - Asynchronous version of Cache::Memcached

SYNOPSIS

# just like Cache::Memcached
use Cache::Memcached::Async;
my $mc = Cache::Memcached::Async->new(servers => [ '127.0.0.1:11211' ]);

DESCRIPTION

This is a stripped-down version of Cache::Memcached that performs gets and sets asynchronously, notifying the caller of completion via the Danga::Socket loop.

It's used almost exactly like Cache::Memcached, except that get() and set() are allowed a callback parameter.

Multi-gets are not supported.

METHODS

For all the below methods, exptime and timeout are in seconds, and callback will be fired upon response from the server. callback may be undef.

new, add, replace, set, and delete all inherit semantics from Cache::Memcached.

Unlike Cache::Memcached, incr and decr do not return the new value of the key.

Cache::Memcached::Async->new()
$mc->delete($key, timeout => $timeout_seconds, callback => \&callback);
$mc->add($key, $value, exptime => $expiration, timeout => $timeout, callback => \&callback);
$mc->replace($key, $value, exptime => $expiration_seconds, timeout => $timeout_seconds, callback => \&callback);
$mc->set($key, $value, exptime => $expiration_seconds, timeout => $timeout_seconds, callback => \&callback);
$mc->incr($key, $step, timeout => $timeout_seconds, callback => \&callback);
$mc->decr($key, $step, timeout => $timeout_seconds, callback => \&callback);
$mc->get($key, timeout => $timeout_seconds, callback => \&callback);

For get(), callback is passed the cached value on hit, or undef on miss.

SEE ALSO

Cache::Memcached

AUTHOR

Jonathan Steinert <hachi@cpan.org>

Adam Thomason <athomason@sixapart.com>

COPYRIGHT AND LICENSE

Copyright (C) 2010 by Six Apart, Ltd.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.5 or, at your option, any later version of Perl 5 you may have available.