NAME

XAO::DO::Cache::Memcached - memcached back-end for XAO::Cache

SYNOPSIS

You should not use this object directly, it is a back-end for XAO::Cache.

if($backend->exists(\@c)) {
    return $backend->get(\@c);
}

DESCRIPTION

This back end uses either Memcached::Client (preferred) or Cache::Memcached modules to store and access distributed data in memcached servers.

It does not work without special support data stored in the site configuration:

/cache/memcached => {
    servers             => [ '192.168.0.100','192.168.0.101' ],
    compress_threshold  => 15000,
    ...
},

The only default is having namespace set to the current site name so that the same keys in different sites don't overlap. If you feel adventurous you can explicitly set "namespace" to an empty string in the config to enable cross-site data caching.

The keys are built from cache name and concatenated coordinate values.

NOTE: The memcached backend does not work well on nameless caches. The name in that case will be simply "$self" (typically something like XAO::DO::Cache::Memcached=GLOB(0x8d850f0)) -- which almost makes the cache useless, as several instances of the process will store data duplicates. Don't do that.

Thankfully all caches used through $config->cache interface have names by definition.

The XAO::Cache "size" parameter is ignored and must be controlled in memcached configuration. The "expire" argument is given to MemCacheD to honor and is not locally enforced.

A couple additional cache parameters are accepted on a per-cache level:

separator       => used for building cache keys from coordinates
digest_keys     => if set SHA-1 digests are used instead of actual
                   concatenated coordinate keys
debug           => if set then dprint is used for extra logging
value_maxlength => maximum length of an individual value

METHODS

drop (@)

Drops an element from the cache.

drop (@)

Drops all elements from the cache.

get (\@)

Retrieves an element from the cache. Does not validate expiration time, trusts memcached on that.

make_key (\@)

Makes a key from the given reference to a list of coordinates.

put (\@\$)

Add a new element to the cache.

setup (%)

Sets expiration time and maximum cache size.

AUTHORS

Copyright (c) 2013 Andrew Maltsev <am@ejelta.com>.

SEE ALSO

Have a look at: XAO::Cache, XAO::Objects, XAO::Base, XAO::FS, XAO::Web.