MemcacheTiered

Filepath: phork/php/cache/memcache/MemcacheTiered.class.php

The MemcacheTiered class is a caching adaptor that uses the PHP Memcache module to cache the data in memcached.

In addition to wrapping PHP's standard Memcache functionality this adds the ability to cache data in namespaces. This allows you to easily flush a single namespace without having to flush the entire cache.

The cache configuration file defines the server pool and whether or not zlib compression is turned on by default.


Configuration Example

//the cache type must have a corresponding class
$arrConfig['Type'] = 'Memcache';


//the cache server(s) for the base tier
$arrConfig['Tiers']['Base']['Servers'] = array(
    array(
        'Host'  => 'localhost',
        'Port' => 11211,
        'Persistent' => true,
        'Weight' => 1,
        'Timeout' => 1
    )
);

//if this is set to MEMCACHE_COMPRESSED then the data will be compressed with zlib
$arrConfig['Tiers']['Base']['Compressed'] = MEMCACHE_COMPRESSED;


//the cache server(s) for the presentation tier
$arrConfig['Tiers']['Presentation']['Servers'] = array(
    array(
        'Host'  => 'localhost',
        'Port' => 11212,
        'Persistent' => true,
        'Weight' => 1,
        'Timeout' => 1
    )
);

//if this is set to MEMCACHE_COMPRESSED then the data will be compressed with zlib
$arrConfig['Tiers']['Presentation']['Compressed'] = MEMCACHE_COMPRESSED;