/** * Initializes this sfCache instance. * * Available options: * * * see sfCache for options available for all drivers * * @see sfCache */ public function initialize($options = array()) { parent::initialize($options); if (!function_exists('apc_store') || !ini_get('apc.enabled')) { throw new sfInitializationException('You must have APC installed and enabled to use sfAPCCache class.'); } }
/** * Initializes this sfCache instance. * * Available options: * * * memcache: A memcache object (optional) * * * host: The default host (default to localhost) * * port: The port for the default server (default to 11211) * * persistent: true if the connection must be persistent, false otherwise (true by default) * * * servers: An array of additional servers (keys: host, port, persistent) * * * see sfCache for options available for all drivers * * @see sfCache */ public function initialize($options = array()) { parent::initialize($options); if (!class_exists('Memcache')) { throw new sfInitializationException('You must have memcache installed and enabled to use sfMemcacheCache class.'); } if ($this->getOption('memcache')) { $this->memcache = $this->getOption('memcache'); } else { $this->memcache = new Memcache(); if ($this->getOption('servers')) { foreach ($this->getOption('servers') as $server) { $port = isset($server['port']) ? $server['port'] : 11211; if (!$this->memcache->addServer($server['host'], $port, isset($server['persistent']) ? $server['persistent'] : true)) { throw new sfInitializationException(sprintf('Unable to connect to the memcache server (%s:%s).', $server['host'], $port)); } } } else { $method = $this->getOption('persistent', true) ? 'pconnect' : 'connect'; if (!$this->memcache->{$method}($this->getOption('host', 'localhost'), $this->getOption('port', 11211), $this->getOption('timeout', 1))) { throw new sfInitializationException(sprintf('Unable to connect to the memcache server (%s:%s).', $this->getOption('host', 'localhost'), $this->getOption('port', 11211))); } } } }
/** * Initializes this sfCache instance. * * Available options: * * * see sfCache for options available for all drivers * * @see sfCache */ public function initialize($options = array()) { parent::initialize($options); if (!function_exists('eaccelerator_put') || !ini_get('eaccelerator.enable')) { throw new sfInitializationException('You must have EAccelerator installed and enabled to use sfEAcceleratorCache class (or perhaps you forgot to add --with-eaccelerator-shared-memory when installing).'); } }
/** * Initializes this sfCache instance. * * Available options: * * * cache_dir: The directory where to put cache files * * * see sfCache for options available for all drivers * * @see sfCache */ public function initialize($options = array()) { parent::initialize($options); if (!$this->getOption('cache_dir')) { throw new sfInitializationException('You must pass a "cache_dir" option to initialize a sfFileCache object.'); } $this->setcache_dir($this->getOption('cache_dir')); }
/** * Initializes this sfCache instance. * * Available options: * * * cache_dir: The directory where to put cache files * * * see sfCache for options available for all drivers * * @see sfCache */ public function initialize($options = array()) { if (!isset($options['cache_dir'])) { $options['cache_dir'] = "../cache/"; } parent::initialize($options); $this->setcache_dir("../cache/"); }
/** * Initializes this sfCache instance. * * Available options: * * * see sfCache for options available for all drivers * * @see sfCache */ public function initialize($options = array()) { parent::initialize($options); if (!function_exists('xcache_set')) { throw new sfInitializationException('You must have XCache installed and enabled to use sfXCacheCache class.'); } if (!ini_get('xcache.var_size')) { throw new sfInitializationException('You must set the "xcache.var_size" variable to a value greater than 0 to use sfXCacheCache class.'); } }
/** * Initializes this sfCache instance. * * Available options: * * * database: File where to put the cache database (or :memory: to store cache in memory) * * * see sfCache for options available for all drivers * * @see sfCache */ public function initialize($options = array()) { if (!extension_loaded('sqlite')) { throw new sfConfigurationException('sfSQLiteCache class needs "sqlite" extension to be loaded.'); } parent::initialize($options); if (!$this->getOption('database')) { throw new sfInitializationException('You must pass a "database" option to initialize a sfSQLiteCache object.'); } $this->setDatabase($this->getOption('database')); }
/** * Initializes this sfCache instance. * * If SASL auth is available, it will be configured. * * Available options: * * * memcached: A memcached object (optional) * * * host: The default host (default to localhost) * * port: The port for the default server (default to 11211) * * weight: true if the connection must be persistent, false otherwise (true by default) * * username: The username to use for SASL auth. * * password: The password to use for SASL auth. * * * servers: An array of additional servers (keys: host, port, weight) * * * see sfCache for options available for all drivers * * @see sfCache */ public function initialize($options = array()) { parent::initialize($options); if (!extension_loaded('memcached')) { throw new sfInitializationException('You must have memcached installed and enabled to use sfMemcachedSaslCache class.'); } if ($this->getOption('memcached')) { $this->memcached = $this->getOption('memcached'); } else { $this->memcached = new Memcached(); if ($this->getOption('username') and $this->getOption('password')) { $this->configureSasl(); } if ($this->getOption('servers')) { $this->memcached->addServers($this->getOption('servers')); } else { $this->memcached->addServer($this->getOption('host', 'localhost'), $this->getOption('port', 11211), $this->getOption('weight', 100)); } } }
public function initialize($options = array()) { parent::initialize($options); if (!$this->getOption('dsn')) { throw new sfConfigurationException('Please provide connection DSN'); } $dsn = $this->getOption('dsn'); $new = false; if (false !== strpos($dsn, ':memory:')) { $new = true; } else { $filepath = substr($dsn, strpos($dsn, ':') + 1); if (!is_dir($dirname = dirname($filepath))) { mkdir($dirname, 0755, true); } $new = !is_file($filepath); } $this->dbh = new PDO($dsn, $this->getOption('username', null), $this->getOption('password', null), $this->getOption('driver_options', array())); $this->getBackend()->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $this->getBackend()->sqliteCreateFunction('regexp', 'preg_match'); if ($new) { $this->createSchema(); } }
public function get($key) { return $this->cache->get($key); }
/** * Initializes this sfCache instance. * * Available options: * * * see sfCache for options available for all drivers * * @see sfCache */ public function initialize($options = array()) { parent::initialize($options); $this->enabled = function_exists('apc_store') && ini_get('apc.enabled'); }
/** * Instantiate Rediska client and initialise it with all servers listed in the instance * * Available options : * * instance: which instance of redis servers to work with (defined in app.yml, app_redis_default by default) * * @see sfCache */ public function initialize($options = array()) { parent::initialize($options); $instance = $this->getOption('instance', 'default'); $this->_rediska = sfRediska::getInstance($instance); }
/** * Initialization process based on parent but without calling parent method * * @see sfCache::initialize * @throws sfInitializationException * @param array $options */ public function initialize($options = array()) { parent::initialize((array) $options); $this->contentTagHandler = new sfContentTagHandler(); $cacheClassName = $this->getOption('storage.class'); if (!$cacheClassName) { throw new sfInitializationException(sprintf('You must pass a "storage.class" option to initialize a %s object.', __CLASS__)); } if (!class_exists($cacheClassName, true)) { throw new sfInitializationException(sprintf('Data cache class "%s" not found', $cacheClassName)); } # check is valid class $this->cache = new $cacheClassName($this->getOption('storage.param', array())); if (!$this->cache instanceof sfCache) { throw new sfInitializationException('Data cache class is not instance of sfCache.'); } if (!$this->getOption('logger.class')) { throw new sfInitializationException(sprintf('You must pass a "logger.class" option to initialize a %s object.', __CLASS__)); } $loggerClassName = $this->getOption('logger.class'); if (!class_exists($loggerClassName, true)) { throw new sfInitializationException(sprintf('Logger cache class "%s" not found', $loggerClassName)); } $this->logger = new $loggerClassName($this->getOption('logger.param', array())); if (!$this->logger instanceof sfCacheTagLogger) { throw new sfInitializationException(sprintf('Logger class is not instance of sfCacheTagLogger, got "%s"', get_class($this->logger))); } }
/** * Available options : * * * connection: Configuration key to connection parameters * * @see sfCache */ public function initialize($options = array()) { parent::initialize($options); $this->redis = new Predis\Client(); }