Oracle 5.0 Reference Manual page 1389

Table of Contents

Advertisement

Once the
Cache::Memcached
methods to store and retrieve information from the
get()
cache are automatically serialized and deserialized using the
The
Cache::Memcached
relate to the generic methods as shown in the table.
Cache::Memcached
get()
get_multi(keys)
set()
add()
replace()
delete()
incr()
decr()
Below is a complete example for using
#!/usr/bin/perl
use Cache::Memcached;
use DBI;
use Data::Dumper;
# Configure the memcached server
my $cache = new Cache::Memcached {
'servers' => [
'localhost:11211',
],
};
# Get the film name from the command line
# memcached keys must not contain spaces, so create
# a key name by replacing spaces with underscores
my $filmname = shift or die "Must specify the film name\n";
my $filmkey = $filmname;
$filmkey =~ s/ /_/;
# Load the data from the cache
my $filmdata = $cache->get($filmkey);
# If the data wasn't in the cache, then we load it from the database
if (!defined($filmdata))
{
$filmdata = load_filmdata($filmname);
if (defined($filmdata))
{
# Set the data into the cache, using the key
if ($cache->set($filmkey,$filmdata))
{
print STDERR "Film data loaded from database and cached\n";
}
else
{
print STDERR "Couldn't store to cache\n";
Developing a
memcached
object instance has been configured, you can use the
interface supports the following methods for storing/retrieving data, and
Function
memcached
1369
Application
servers. Objects stored in the
memcached
module.
Storable
Equivalent Generic Method
Generic get().
Gets multiple
from memcache using just
keys
one query. Returns a hash reference of key/value
pairs.
Generic set().
Generic add().
Generic replace().
Generic delete().
Generic incr().
Generic decr().
with Perl and the
Cache::Memcached
and
set()
module:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents