GX::Cache::Memcached - Base class for Memcached-based cache components
package MyApp::Cache::Default; use GX::Cache::Memcached; __PACKAGE__->setup( servers => [ '127.0.0.1:11211' ] ); 1;
This module provides the GX::Cache::Memcached class which extends the GX::Cache class.
new
Returns the cache component instance.
$cache = $cache_class->new;
$cache ( GX::Cache::Memcached object )
$cache
GX::Exception
All public methods can be called both as instance and class methods.
add
Like set(), but only stores the given value if the key does not already exist.
set()
$result = $cache->add( $key, $value ); $result = $cache->add( $key, $value, $expire_time );
$key ( string )
$key
$value ( scalar )
$value
$expire_time ( integer ) [ optional ]
$expire_time
$result ( bool )
$result
clear
Clears the cache.
$cache->clear;
get
Retrieves the value(s) for the given key(s).
$value = $cache->get( $key );
@values = $cache->get( @keys );
@keys ( strings )
@keys
@values ( scalars )
@values
If get() is called with more than one key but in scalar context, it returns a reference to a hash with the retrieved key / value pairs.
get()
$pairs = $cache->get( @keys );
$pairs ( HASH reference )
$pairs
HASH
memcached
Returns the associated Cache::Memcached instance.
$memcached = $cache->memcached;
$memcached ( Cache::Memcached object )
$memcached
namespace
Returns the namespace key prefix.
$namespace = $cache->namespace;
$namespace ( string | undef )
$namespace
undef
options
Returns a list with the additional options that are passed to the Cache::Memcached constructor.
%options = $cache->options;
%options ( named list )
%options
remove
Removes the specified key / value pair. Returns true if the pair was actually stored and successfully removed, otherwise false.
$result = $cache->remove( $key );
replace
Like set(), but only stores the given value if the key already exists.
$result = $cache->replace( $key, $value ); $result = $cache->replace( $key, $value, $expire_time );
servers
Returns a list with the memcached server addresses.
@servers = $cache->servers;
@servers ( strings )
@servers
set
Unconditionally sets the specified key to the given value. Returns true on success, otherwise false.
$result = $cache->set( $key, $value ); $result = $cache->set( $key, $value, $expire_time );
setup
Sets up the component.
$cache->setup( %options );
namespace ( string | undef )
A key prefix. Defaults to the class name of the component.
options ( HASH reference )
Additional options for the Cache::Memcached constructor.
servers ( ARRAY reference )
ARRAY
A list of memcached server addresses. Defaults to a single address: "127.0.0.1:11211".
Cache::Memcached
Jörg A. Uzarek <uzarek@runlevelnull.de>
Copyright (c) 2009-2011 Jörg A. Uzarek.
This module is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License Version 3 as published by the Free Software Foundation.
To install GX, copy and paste the appropriate command in to your terminal.
cpanm
cpanm GX
CPAN shell
perl -MCPAN -e shell install GX
For more information on module installation, please visit the detailed CPAN module installation guide.