diff --git a/src/Storm/Cache.php b/src/Storm/Cache.php index 2b3513f36c5f2793df0edf074b2f594d048f338a..ada41ee540e773a478a234ee08683a35da820e58 100644 --- a/src/Storm/Cache.php +++ b/src/Storm/Cache.php @@ -82,17 +82,18 @@ class Storm_Cache { } - public function setEnabled($enabled) { $this->_enabled = $enabled; return $this; } + public function setCache($zend_cache) { $this->_zend_cache = $zend_cache; return $this; } + public function memoize($key, $callback) { if(!$this->_enabled) return $callback(); @@ -105,6 +106,7 @@ class Storm_Cache { return $data; } + public function getCache() { if(!isset($this->_zend_cache)) $this->_zend_cache = static::getDefaultZendCache(); @@ -143,7 +145,7 @@ class Storm_Cache { public function addSeedToKey($key) { - return md5(json_encode([$this->_getRealSeed(), $key])); + return $this->_getRealSeed() . '_' . md5(json_encode([$key])); } @@ -159,13 +161,18 @@ class Storm_Cache { protected function _generateRealSeed() { - $my_real_seed = uniqid(static::$_seed . '_'); + $my_real_seed = uniqid(static::$_seed); $this->getCache()->save($my_real_seed, static::$_seed); return $my_real_seed; } + public function getRealSeed() { + return $this->_getRealSeed(); + } + + public function clean(){ static::$_real_seed = $this->_generateRealSeed(); return $this;