* @package Mammut\Storage\CachedStore * @since 1.1.0.0 */ class CachedLamdaStore extends CachedStore { private $storeL; private $fetchL; private $deleteL; private $existL; /** * Creates a new cached stroage * @param iCache $cache * @param \Closure $store a function with two parameters: key and value * @param \Closure $fetch a function with one parameter: key * @param \Closure $delete a function with one parameter: key * @param \Closure $exist a function with one parameter: key * @param string $cachePrefix an optional prefix for the keys in the cache */ public function __construct(iCache $cache, \Closure $store, \Closure $fetch, \Closure $delete, \Closure $exist, $cachePrefix = '' ) { $this->cacheKeyPrefix = $cachePrefix; $this->cache = $cache; $this->storeL = $store; $this->fetchL = $fetch; $this->deleteL = $delete; $this->existL = $exist; } protected function storePersistend($key, $value) { $c = $this->storeL; $c($key,$value); } protected function fetchPersistend($key) { $c = $this->fetchL; return $c($key); } protected function existPersistend($key) { $c = $this->existL; return $c($key); } protected function deletePersistend($key) { $c = $this->deleteL; return $c($key); } }