Memcached is a small library for using memcached with CakePHP. While CakePHP provides its own library for interacting with several different types of cache, it can be somewhat difficult to manage items in a cache that don’t all need the same exact configuration.
Memcached allows you to specify separate time outs for each key. It also allows you to tag each item so that a large number of items can easy be removed from the cache.
There are two ways to use Memcached. The first uses a more traditional syntax.
$cache_name = 'some_cache_name'; if (!$data = $this->cache->load($cache_name, $ignore)) { // Read data here $this->cache->save($cache_name, $data, $timeout, $tags); } return $data;
The second is designed to feel more like a CakePHP model:
$this->cache->key = 'some_cache_name'; if (!$data = $this->cache->read()) { // Read data here $this->cache->update($data, $timeout, $tags); } return $data;
$ignore, supported by both Memcached::load and Memcached::read, will ignore any cached data. This is useful if you wish to use the same function to read data and to update the cache.
Download version 1.0