View Source

<ac:macro ac:name="unmigrated-inline-wiki-markup"><ac:plain-text-body><![CDATA[{zone-template-instance:ZFPROP:Proposal Zone Template}

{zone-data:component-name}
Zend_Cache_Backend_Redis
{zone-data}

{zone-data:proposer-list}
[Rostyslav Mykhajliw|mailto:necromant2005@gmail.com]
{zone-data}

{zone-data:liaison}
http://github.com/necromant2005/zeus-redis
{zone-data}

{zone-data:revision}
1.0 - 32 December 2010: Beta specification.
{zone-data}

{zone-data:overview}
Zend_Cache_Backend_Redis is a simple backend for Zend\Cache in Redis.
[GitHup sources|https://github.com/necromant2005/zeus-redis]
{zone-data}

{zone-data:references}
* [Redis|http://redis.io/]
* [Wikipedia|http://en.wikipedia.org/wiki/Redis_(data_store)]
* [Redis command specification|http://redis.io/commands]
* [Rediska alternative php client|http://rediska.geometria-lab.net/]
{zone-data}

{zone-data:requirements}
Currently we've got standard adapter for Redis

* This component *will* provide interface to Redis.
* This component *will* use Redis as Zend\Cache\Backend.
* This component *will* allow get/put/delete operations in Redis.
* This component *will not* support tags in Zend\Cache.
{zone-data}

{zone-data:dependencies}
* Zend\Exception
* Zend\Cache\Backend\AbstractBackend
{zone-data}

{zone-data:operation}
The primary goal of this component is realize Zend\Cache\Backend\AbstractBackend interface for Redis and allow use it natively from Zend Framework, also integrate into Zend\Cache\Cache factory method

* auto serialization/unserialization data
* allow put data by key
* allow get data by key
* allow delete data by key
* infinite lifetime support
{zone-data}

{zone-data:milestones}

* Milestone 1: \[DONE\] Create a base operation get/set/delete
* Milestone 2: \[DONE\] Realize interface Zend\Cache\Backend\AbstractBackend
* Milestone 3: Write a stable documentation.

{zone-data}

{zone-data:class-list}
* Zend\Cache\Backend\Redis
{zone-data}

{zone-data:use-cases}
||UC-01||

... (see good use cases book)
{zone-data}

{zone-data:skeletons}
{code}
class Zend\Cache\Backend\Redis extends Zend\Cache\Backend\AbstractBackend
{
/**
* Test if a cache is available for the given id and (if yes) return it (false else)
*
* @param string $id cache id
* @param boolean $doNotTestCacheValidity if set to true, the cache validity won't be tested
* @return string|false cached datas
*/
public function load($id, $doNotTestCacheValidity = false)
{
return false;
}

/**
* Test if a cache is available or not (for the given id)
*
* @param string $id cache id
* @return mixed false (a cache is not available) or "last modified" timestamp (int) of the available cache record
*/
public function test($id)
{
return false;
}

/**
* Save some string datas into a cache record
*
* Note : $data is always "string" (serialization is done by the
* core not by the backend)
*
* @param string $data Datas to cache
* @param string $id Cache id
* @param array $tags Array of strings, the cache record will be tagged by each string entry
* @param int $specificLifetime If != false, set a specific lifetime for this cache record (null => infinite lifetime)
* @return boolean true if no problem
*/
public function save($data, $id, $tags = array(), $specificLifetime = false)
{
return true;
}

/**
* Remove a cache record
*
* @param string $id cache id
* @return boolean true if no problem
*/
public function remove($id)
{
return true;
}

/**
* Clean some cache records
*
* Available modes are :
* 'all' (default) => remove all cache entries ($tags is not used)
* 'old' => remove too old cache entries ($tags is not used)
* 'matchingTag' => remove cache entries matching all given tags
* ($tags can be an array of strings or a single string)
* 'notMatchingTag' => remove cache entries not matching one of the given tags
* ($tags can be an array of strings or a single string)
* 'matchingAnyTag' => remove cache entries matching any given tags
* ($tags can be an array of strings or a single string)
*
* @param string $mode clean mode
* @param tags array $tags array of tags
* @return boolean true if no problem
*/
public function clean($mode = Cache\CacheCache\Cache::CLEANING_MODE_ALL, $tags = array())
{
return true;
}

/**
* Return an array of stored cache ids
*
* @return array array of stored cache ids (string)
*/
public function getIds()
{
return array();
}

/**
* Return an array of stored tags
*
* @return array array of stored tags (string)
*/
public function getTags()
{
return array();
}

/**
* Return an array of stored cache ids which match given tags
*
* In case of multiple tags, a logical AND is made between tags
*
* @param array $tags array of tags
* @return array array of matching cache ids (string)
*/
public function getIdsMatchingTags($tags = array())
{
return array();
}

/**
* Return an array of stored cache ids which don't match given tags
*
* In case of multiple tags, a logical OR is made between tags
*
* @param array $tags array of tags
* @return array array of not matching cache ids (string)
*/
public function getIdsNotMatchingTags($tags = array())
{
return array();
}

/**
* Return an array of stored cache ids which match any given tags
*
* In case of multiple tags, a logical AND is made between tags
*
* @param array $tags array of tags
* @return array array of any matching cache ids (string)
*/
public function getIdsMatchingAnyTags($tags = array())
{
return array();
}

/**
* Return the filling percentage of the backend storage
*
* @return int integer between 0 and 100
* @throws \Zend\Cache\Exception
*/
public function getFillingPercentage()
{
return 0;
}

/**
* Return an array of metadatas for the given cache id
*
* The array must include these keys :
* - expire : the expire timestamp
* - tags : a string array of tags
* - mtime : timestamp of last modification time
*
* @param string $id cache id
* @return array array of metadatas (false if the cache id is not found)
*/
public function getMetadatas($id)
{
return false;
}

/**
* Give (if possible) an extra lifetime to the given cache id
*
* @param string $id cache id
* @param int $extraLifetime
* @return boolean true if ok
*/
public function touch($id, $extraLifetime)
{
return false;
}

/**
* Return an associative array of capabilities (booleans) of the backend
*
* The array must include these keys :
* - automatic_cleaning (is automating cleaning necessary)
* - tags (are tags supported)
* - expired_read (is it possible to read expired cache records
* (for doNotTestCacheValidity option for example))
* - priority does the backend deal with priority when saving
* - infinite_lifetime (is infinite lifetime can work with this backend)
* - get_list (is it possible to get the list of cache ids and the complete list of tags)
*
* @return array associative of with capabilities
*/
public function getCapabilities()
{
return array(
'automatic_cleaning' => true,
'tags' => true,
'expired_read' => true,
'priority' => true,
'infinite_lifetime' => true,
'get_list' => true,
);
}

/**
* PUBLIC METHOD FOR UNIT TESTING ONLY !
*
* Force a cache record to expire
*
* @param string $id cache id
*/
public function ___expire($id)
{
}
}
{code}
{zone-data}

{zone-template-instance}]]></ac:plain-text-body></ac:macro>