public function __construct() { $di = \Phalcon\Di::getDefault(); $cache_driver = $di['cache_driver']; $pool = new \Stash\Pool($cache_driver); $pool->setNamespace(\FA\Cache::getSitePrefix('doctrine')); $this->_cache = $pool; }
/** * This function is defined by the SessionHandlerInterface and is for PHP's * internal use. It is called randomly based on the session.gc_divisor, * session.gc_probability and session.gc_lifetime settings, which should be * set according to the drivers used. Those with built in eviction * mechanisms will not need this functionality, while those without it will. * It is also possible to disable the built in garbage collection (place * gc_probability as zero) and call the "purge" function on the Stash\Pool * class directly. * * @param int $maxlifetime * @return bool */ public function gc($maxlifetime) { return $this->pool->purge(); }
$cache_driver = new \Stash\Driver\Memcache(); $cache_driver->setOptions($cache_config['memcached']); break; case 'file': $cache_driver = new \Stash\Driver\FileSystem(); $cache_driver->setOptions($cache_config['file']); break; default: case 'memory': case 'ephemeral': $cache_driver = new \Stash\Driver\Ephemeral(); break; } // Register Stash as session handler if necessary. if (!$cache_driver instanceof \Stash\Driver\Ephemeral) { $pool = new \Stash\Pool($cache_driver); $pool->setNamespace(\FA\Cache::getSitePrefix('session')); $session = new \Stash\Session($pool); \Stash\Session::registerHandler($session); } return $cache_driver; }); $di->set('cache', array('className' => '\\FA\\Cache', 'arguments' => array(array('type' => 'service', 'name' => 'cache_driver'), array('type' => 'parameter', 'value' => 'user')))); // Register URL handler. $di->setShared('url', array('className' => '\\FA\\Url', 'arguments' => array(array('type' => 'service', 'name' => 'config'), array('type' => 'service', 'name' => 'request'), array('type' => 'service', 'name' => 'dispatcher')))); // Register session service. $di->setShared('session', '\\FA\\Session'); // Register CSRF prevention security token service. $di->setShared('csrf', array('className' => '\\FA\\Csrf', 'arguments' => array(array('type' => 'service', 'name' => 'session')))); // Register view helpers. $di->setShared('viewHelper', '\\FA\\Phalcon\\Service\\ViewHelper');
/** * @param string $cache_level * @return \Stash\Pool */ public static function getCache($cache_level = 'user') { static $caches; static $cache_driver; if (!$caches) { $caches = array(); } if (isset($caches[$cache_level])) { return $caches[$cache_level]; } if (!$cache_driver) { $cache_driver = self::getCacheDriver(); } $pool = new \Stash\Pool($cache_driver); $pool->setNamespace(self::getSitePrefix($cache_level)); $caches[$cache_level] = $pool; return $pool; }
public function __construct(\Stash\Interfaces\DriverInterface $cache_driver, $cache_level = 'user') { $pool = new \Stash\Pool($cache_driver); $pool->setNamespace(self::getSitePrefix($cache_level)); $this->_cache = $pool; }
/** * Creates the pools with user defined options * * @param \Silex\Application $app The silex app * * @return \Pimple $pools The pools in the pimple container */ private static function createPools($app) { $pools = new \Pimple(); foreach ($app['pools.options'] as $name => $options) { $pool = new \Stash\Pool(self::fetchDriver($options)); $pool->setLogger(self::fetchLogger($app, $options)); $pools[$name] = $pools->share(function () use($pool) { return $pool; }); } return $pools; }
public function init() { $pool = new Stash\Pool(); $pool->set('index', 'index'); $pool - get('index'); }