diff --git a/library/Zend/Cache/Exception/MissingDependencyException.php b/library/Zend/Cache/Exception/MissingDependencyException.php index cf57f115b46..be8bf69d942 100644 --- a/library/Zend/Cache/Exception/MissingDependencyException.php +++ b/library/Zend/Cache/Exception/MissingDependencyException.php @@ -2,5 +2,5 @@ namespace Zend\Cache\Exception; -class MissingDependencyException extends RuntimeException implements \Zend\Cache\Exception +class MissingDependencyException extends RuntimeException {} diff --git a/library/Zend/Cache/Pattern.php b/library/Zend/Cache/Pattern.php index d76e8e27d7c..eb043364dfa 100644 --- a/library/Zend/Cache/Pattern.php +++ b/library/Zend/Cache/Pattern.php @@ -16,14 +16,14 @@ public function __construct($options = array()); * Set pattern options * * @param array|Traversable $options - * @return Zend\Cache\Pattern + * @return Pattern */ public function setOptions($options); /** * Get all pattern options * - * return array + * @return array */ public function getOptions(); diff --git a/library/Zend/Cache/Pattern/AbstractPattern.php b/library/Zend/Cache/Pattern/AbstractPattern.php index db6cdd91878..586fbaf21d6 100644 --- a/library/Zend/Cache/Pattern/AbstractPattern.php +++ b/library/Zend/Cache/Pattern/AbstractPattern.php @@ -7,11 +7,23 @@ abstract class AbstractPattern implements Cache\Pattern { + /** + * Constructor + * + * @param array|Traversable $options + */ public function __construct($options = array()) { $this->setOptions($options); } + /** + * Set pattern options + * + * @param array|Traversable $options + * @return AbstractPattern + * @throws InvalidArgumentException + */ public function setOptions($options) { if (!($options instanceof Traversable) && !is_array($options)) { @@ -29,6 +41,11 @@ public function setOptions($options) return $this; } + /** + * Get all pattern options + * + * @return array + */ public function getOptions() { return array(); diff --git a/library/Zend/Cache/Pattern/CallbackCache.php b/library/Zend/Cache/Pattern/CallbackCache.php index c63a55ee3f8..f0241e33c13 100644 --- a/library/Zend/Cache/Pattern/CallbackCache.php +++ b/library/Zend/Cache/Pattern/CallbackCache.php @@ -22,6 +22,12 @@ class CallbackCache extends AbstractPattern */ protected $_cacheOutput = true; + /** + * Constructor + * + * @param array|Traversable $options + * @throws InvalidArgumentException + */ public function __construct($options = array()) { parent::__construct($options); @@ -31,6 +37,11 @@ public function __construct($options = array()) } } + /** + * Get all pattern options + * + * @return array + */ public function getOptions() { $options = parent::getOptions(); @@ -180,6 +191,17 @@ public function generateKey($callback, array $args = array(), array $options = a return $this->_generateKey($callback, $args, $options); } + /** + * Generate a unique key in base of a key representing the callback part + * and a key representing the arguments part merged using md5($callbackKey.$argumentsKey). + * + * @param callback $callback A valid callback + * @param array $args Callback arguments + * @param array $options Options + * @return string + * @throws \Zend\Cache\Exception\InvalidArgumentException + * @throws \Zend\Cache\Exception\RuntimeException + */ protected function _generateKey($callback, array $args, array $options) { $callbackKey = ''; diff --git a/library/Zend/Cache/Pattern/CaptureCache.php b/library/Zend/Cache/Pattern/CaptureCache.php index 15fb4113818..f43521c3b01 100644 --- a/library/Zend/Cache/Pattern/CaptureCache.php +++ b/library/Zend/Cache/Pattern/CaptureCache.php @@ -54,11 +54,21 @@ class CaptureCache extends AbstractPattern */ protected $_tags = array(); + /** + * Constructor + * + * @param array|Traversable $options + */ public function __construct($options = array()) { parent::__construct($options); } + /** + * Get all pattern options + * + * @return array + */ public function getOptions() { return array( @@ -69,34 +79,67 @@ public function getOptions() ); } + /** + * Set public directory + * + * @param null|string $dir + * @return CaptureCache + */ public function setPublicDir($dir) { $this->_publicDir = $dir; return $this; } + /** + * Get public directory + * + * @return null|string + */ public function getPublicDir() { return $this->_publicDir; } + /** + * Set index filename + * + * @param string $filename + * @return CaptureCache + */ public function setIndexFilename($filename) { $this->_indexFilename = (string)$filename; return $this; } + /** + * Get index filename + * + * @return string + */ public function getIndexFilename() { return $this->_indexFilename; } + /** + * Set file locking + * + * @param bool $flag + * @return CaptureCache + */ public function setFileLocking($flag) { $this->_fileLocking = (boolean)$flag; return $this; } + /** + * Get file locking + * + * @return bool + */ public function getFileLocking() { return $this->_fileLocking; @@ -106,7 +149,7 @@ public function getFileLocking() * Set a storage for tagging * * @param \Zend\Cache\Storage\Adapter $storage - * @return \Zend\Cache\Pattern\CaptureCache + * @return CaptureCache */ public function setTagStorage(Adapter $storage) { @@ -128,7 +171,7 @@ public function getTagStorage() * Set cache item key to store tags * * @param $tagKey string - * @return Zend\Cache\Pattern\CaptureCache + * @return CaptureCache */ public function setTagKey($tagKey) { @@ -154,7 +197,7 @@ public function getTagKey() * Set tags to store * * @param array $tags - * @return Zend\Cache\Pattern\CaptureCache + * @return CaptureCache */ public function setTags(array $tags) { @@ -205,6 +248,14 @@ public function start($pageId = null, array $options = array()) return false; } + /** + * Get from cache + * + * @param null|string $pageId + * @param array $options + * @return bool|string + * @throws RuntimeException + */ public function get($pageId = null, array $options = array()) { if (($pageId = (string)$pageId) === '') { @@ -226,6 +277,13 @@ public function get($pageId = null, array $options = array()) return false; } + /** + * Checks if a cache with given id exists + * + * @param null|string $pageId + * @param array $options + * @return bool + */ public function exists($pageId = null, array $options = array()) { if (($pageId = (string)$pageId) === '') { @@ -239,6 +297,14 @@ public function exists($pageId = null, array $options = array()) return file_exists($file); } + /** + * Remove from cache + * + * @param null|string $pageId + * @param array $options + * @throws RuntimeException + * @return void + */ public function remove($pageId = null, array $options = array()) { if (($pageId = (string)$pageId) === '') { @@ -257,6 +323,9 @@ public function remove($pageId = null, array $options = array()) } } + /** + * Clear cache + */ public function clear(/*TODO*/) { // TODO @@ -272,6 +341,12 @@ protected function _detectPageId() return $_SERVER['REQUEST_URI']; } + /** + * Get filename for page id + * + * @param string $pageId + * @return string + */ protected function _pageId2Filename($pageId) { $filename = basename($pageId); @@ -283,6 +358,12 @@ protected function _pageId2Filename($pageId) return $filename; } + /** + * Get path for page id + * + * @param string $pageId + * @return string + */ protected function _pageId2Path($pageId) { $path = rtrim(dirname($pageId), '/'); @@ -310,6 +391,12 @@ protected function _flush($output) return false; } + /** + * Save the cache + * + * @param $output + * @throws RuntimeException + */ protected function _save($output) { $path = $this->_pageId2Path($this->_pageId); diff --git a/library/Zend/Cache/Pattern/ClassCache.php b/library/Zend/Cache/Pattern/ClassCache.php index 4a307377d71..1c92ec16a56 100644 --- a/library/Zend/Cache/Pattern/ClassCache.php +++ b/library/Zend/Cache/Pattern/ClassCache.php @@ -15,11 +15,40 @@ class ClassCache extends CallbackCache */ protected $_storage; + /** + * The entity + * + * @var null|string + */ protected $_entity = null; + + /** + * Cache by default + * + * @var bool + */ protected $_cacheByDefault = true; + + /** + * Cache methods + * + * @var array + */ protected $_cacheMethods = array(); + + /** + * Non-cache methods + * + * @var array + */ protected $_nonCacheMethods = array(); + /** + * Constructor + * + * @param array|Traversable $options + * @throws InvalidArgumentException + */ public function __construct($options = array()) { parent::__construct($options); @@ -31,6 +60,11 @@ public function __construct($options = array()) } } + /** + * Get all pattern options + * + * @return array + */ public function getOptions() { $options = parent::getOptions(); diff --git a/library/Zend/Cache/Pattern/ObjectCache.php b/library/Zend/Cache/Pattern/ObjectCache.php index 80fce715367..84e2851f109 100644 --- a/library/Zend/Cache/Pattern/ObjectCache.php +++ b/library/Zend/Cache/Pattern/ObjectCache.php @@ -15,13 +15,54 @@ class ObjectCache extends CallbackCache */ protected $_storage; + /** + * The entity + * + * @var null|object + */ protected $_entity = null; + + /** + * The entity key + * + * @var null|string + */ protected $_entityKey = null; + + /** + * Cache by default + * + * @var bool + */ protected $_cacheByDefault = true; + + /** + * Cache methods + * + * @var array + */ protected $_cacheMethods = array(); + + /** + * Non-cache methods + * + * @var array + */ protected $_nonCacheMethods = array('__tostring'); + + /** + * Cache magic properties + * + * @var bool + */ protected $_cacheMagicProperties = false; + /** + * Constructor + * + * @param array|Traversable $options + * @throws InvalidArgumentException + */ public function __construct($options = array()) { parent::__construct($options); @@ -33,6 +74,11 @@ public function __construct($options = array()) } } + /** + * Get all pattern options + * + * @return array + */ public function getOptions() { $options = parent::getOptions(); diff --git a/library/Zend/Cache/Pattern/OutputCache.php b/library/Zend/Cache/Pattern/OutputCache.php index 4042a9a0bd6..c358333c350 100644 --- a/library/Zend/Cache/Pattern/OutputCache.php +++ b/library/Zend/Cache/Pattern/OutputCache.php @@ -17,8 +17,19 @@ class OutputCache extends AbstractPattern */ protected $_storage; + /** + * The key stack + * + * @var array + */ protected $_keyStack = array(); + /** + * Constructor + * + * @param array|Traversable $options + * @throws InvalidArgumentException + */ public function __construct($options = array()) { parent::__construct($options); @@ -28,6 +39,11 @@ public function __construct($options = array()) } } + /** + * Get all pattern options + * + * @return array + */ public function getOptions() { $options = parent::getOptions();