diff options
Diffstat (limited to 'engine/classes/ElggStaticVariableCache.php')
| -rw-r--r-- | engine/classes/ElggStaticVariableCache.php | 48 |
1 files changed, 39 insertions, 9 deletions
diff --git a/engine/classes/ElggStaticVariableCache.php b/engine/classes/ElggStaticVariableCache.php index 5ace37ddf..9c14fdfba 100644 --- a/engine/classes/ElggStaticVariableCache.php +++ b/engine/classes/ElggStaticVariableCache.php @@ -1,33 +1,42 @@ <?php /** * ElggStaticVariableCache - * Dummy cache which stores values in a static array. Using this makes future replacements to other caching back - * ends (eg memcache) much easier. + * Dummy cache which stores values in a static array. Using this makes future + * replacements to other caching back ends (eg memcache) much easier. * - * @author Curverider Ltd <info@elgg.com> - * @package Elgg - * @subpackage API + * @package Elgg.Core + * @subpackage Cache */ class ElggStaticVariableCache extends ElggSharedMemoryCache { /** * The cache. * - * @var unknown_type + * @var array */ private static $__cache; /** * Create the variable cache. * - * This function creates a variable cache in a static variable in memory, optionally with a given namespace (to avoid overlap). + * This function creates a variable cache in a static variable in + * memory, optionally with a given namespace (to avoid overlap). * - * @param string $namespace The namespace for this cache to write to - note, namespaces of the same name are shared! + * @param string $namespace The namespace for this cache to write to. + * @warning namespaces of the same name are shared! */ function __construct($namespace = 'default') { $this->setNamespace($namespace); $this->clear(); } + /** + * Save a key + * + * @param string $key Name + * @param string $data Value + * + * @return boolean + */ public function save($key, $data) { $namespace = $this->getNamespace(); @@ -36,6 +45,15 @@ class ElggStaticVariableCache extends ElggSharedMemoryCache { return true; } + /** + * Load a key + * + * @param string $key Name + * @param int $offset Offset + * @param int $limit Limit + * + * @return string + */ public function load($key, $offset = 0, $limit = null) { $namespace = $this->getNamespace(); @@ -46,6 +64,13 @@ class ElggStaticVariableCache extends ElggSharedMemoryCache { return false; } + /** + * Invalidate a given key. + * + * @param string $key Name + * + * @return bool + */ public function delete($key) { $namespace = $this->getNamespace(); @@ -54,6 +79,11 @@ class ElggStaticVariableCache extends ElggSharedMemoryCache { return true; } + /** + * Clears the cache for a particular namespace + * + * @return void + */ public function clear() { $namespace = $this->getNamespace(); @@ -63,4 +93,4 @@ class ElggStaticVariableCache extends ElggSharedMemoryCache { ElggStaticVariableCache::$__cache[$namespace] = array(); } -}
\ No newline at end of file +} |
