function __construct() { $driver = new Stash\Driver\FileSystem(); $options = array('path' => __DIR__ . '/../cache/'); $driver->setOptions($options); $this->stash = new Stash\Pool($driver); }
public function buildFilesystemDriver() { $dir = $this->_context->get(tubepress_api_options_Names::CACHE_DIRECTORY); if ($this->_shouldLog) { $this->_logDebug(sprintf('Starting to build API cache driver. User candidate is "<code>%s</code>"', $dir)); } /* * If a path was given, but it's not a directory, let's try to create it. */ if ($dir && !is_dir($dir)) { if ($this->_shouldLog) { $this->_logDebug(sprintf('"<code>%s</code>" is not a directory. Let\'s try to create it...', $dir)); } @mkdir($dir, 0755, true); } /* * If the directory exists, but isn't writable, let's try to change that. */ if ($dir && is_dir($dir) && !is_writable($dir)) { if ($this->_shouldLog) { $this->_logDebug(sprintf('"<code>%s</code>" is a directory but we can\'t write to it. Let\'s try to change that...', $dir)); } @chmod($dir, 0755); } /* * If we don't have a writable directory, use the system temp directory. */ if (!is_dir($dir) || !is_writable($dir)) { if ($this->_shouldLog) { $this->_logDebug(sprintf('We don\'t have a directory that we can use for the API cache. Giving up and falling back to system directory.', $dir)); } $dir = $this->_bootSettings->getPathToSystemCacheDirectory() . '/api-calls'; if ($this->_shouldLog) { $this->_logDebug(sprintf('Final API cache directory is "<code>%s</code>"', $dir)); } } $driver = new \Stash\Driver\FileSystem(); $driver->setOptions(array('path' => $dir)); return $driver; }
protected function _getCache() { $driver = new \Stash\Driver\FileSystem(); $path = dirname(dirname(dirname(__DIR__))) . '/cache'; $driver->setOptions(array('path' => $path)); $pool = new \Stash\Pool($driver); return $pool; }
$di->setShared('acl', array('className' => '\\FA\\Legacy\\Acl', 'arguments' => array(array('type' => 'service', 'name' => 'em'), array('type' => 'service', 'name' => 'auth')))); // Caching $di->setShared('cache_driver', function () use($config) { $cache_config = $config->cache->toArray(); switch ($cache_config['cache']) { case 'redis': $cache_driver = new \Stash\Driver\Redis(); $cache_driver->setOptions($cache_config['redis']); break; case 'memcached': $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;
/** * Return the application-configured driver. * * @return \Stash\Interfaces\DriverInterface */ public static function getCacheDriver() { $di = \Phalcon\Di::getDefault(); $config = $di->get('config'); $cache_config = $config->cache->toArray(); switch ($cache_config['cache']) { case 'redis': $cache_driver = new \Stash\Driver\Redis(); $cache_driver->setOptions($cache_config['redis']); return $cache_driver; break; case 'memcached': $cache_driver = new \Stash\Driver\Memcache(); $cache_driver->setOptions($cache_config['memcached']); return $cache_driver; break; case 'file': $cache_driver = new \Stash\Driver\FileSystem(); $cache_driver->setOptions($cache_config['file']); return $cache_driver; break; default: case 'memory': case 'ephemeral': return new \Stash\Driver\Ephemeral(); break; } }
/** * Connect to filesystem cache * * @return \Stash\Pool */ private function connect() { $driver = new Stash\Driver\FileSystem(); $driver->setOptions(['path' => CACHE_DIR]); return new Stash\Pool($driver); }