Provides an interface into the memcached caching system. Requires the PHP memcache extension to be loaded and memcache to be configured and running on appropriate hosts. See: memcache for detail so on the PHP extension and www.danga.com/memcached/ for the memcache server.
// example single server
$inOptions = array(
cacheWriterMemcache::OPTION_SERVER_HOST => '192.168.10.1',
cacheWriterMemcache::OPTION_SERVER_PORT => '12345',
);
$oCacheWriter = new cacheWriterMemcache($inOptions);
// example of single server and use compression
$inOptions = array(
cacheWriterMemcache::OPTION_SERVERS => array(
0 => array(
cacheWriterMemcache::OPTION_SERVER_HOST => '192.168.10.1',
cacheWriterMemcache::OPTION_SERVER_PORT => '12345',
),
),
cacheWriterMemcache::OPTION_USE_COMPRESSION => true
);
$oCacheWriter = new cacheWriterMemcache($inOptions);
// example of multiple servers using defaults
$inOptions = array(
cacheWriterMemcache::OPTION_SERVERS => array(
0 => array(
cacheWriterMemcache::OPTION_SERVER_HOST => '192.168.10.1',
),
1 => array(
cacheWriterMemcache::OPTION_SERVER_HOST => '192.168.10.2',
),
2 => array(
cacheWriterMemcache::OPTION_SERVER_HOST => '192.168.10.3',
),
3 => array(
cacheWriterMemcache::OPTION_SERVER_HOST => '192.168.10.4',
),
),
);
$oCacheWriter = new cacheWriterMemcache($inOptions);
public __construct([$inOptions = array()], [$inCacheId = null])
Returns a new memcache writer for the cache controller
$inOptions is an associative array of server details and options. It supports 2 formats: 1. Single Server 2. Multi Server
// example single server
$inOptions = array(
cacheWriterMemcache::OPTION_SERVER_HOST => '192.168.10.1',
cacheWriterMemcache::OPTION_SERVER_PORT => '12345',
);
// example of single server and use compression
$inOptions = array(
cacheWriterMemcache::OPTION_SERVERS => array(
0 => array(
cacheWriterMemcache::OPTION_SERVER_HOST => '192.168.10.1',
cacheWriterMemcache::OPTION_SERVER_PORT => '12345',
),
),
cacheWriterMemcache::OPTION_USE_COMPRESSION => true
);
// example of multiple servers using defaults
$inOptions = array(
cacheWriterMemcache::OPTION_SERVERS => array(
0 => array(
cacheWriterMemcache::OPTION_SERVER_HOST => '192.168.10.1',
),
1 => array(
cacheWriterMemcache::OPTION_SERVER_HOST => '192.168.10.2',
),
2 => array(
cacheWriterMemcache::OPTION_SERVER_HOST => '192.168.10.3',
),
3 => array(
cacheWriterMemcache::OPTION_SERVER_HOST => '192.168.10.4',
),
),
);
public static clearCache([$inOptions = array()])
Removes all cached records from memcache instances
public parseOptions([$inOptions = array()])
Parses the options assigning as appropriate
public runGc()
Runs garbage collection
public getLifetime()
Override getLifetime to add in additional checks for memcache
public getMemcache()
Returns $_Memcache
public setMemcache($inMemcache)
Set $_Memcache to $inMemcache
public getUseCompression()
Returns true if compression should be used
public getOptionsSet()
Returns $_OptionsSet
public setOptionsSet($inOptionsSet)
Set $_OptionsSet to $inOptionsSet
Posted by: Scorpio Documentor (Writer), in Cache on 19 Nov 2009 @ 20:30
Tags: cache, cachewriter, cachewritermemcache,
This
work is licenced under a
Creative Commons Licence.