/** * @param string $prefix * @throws \RuntimeException */ public function __construct($prefix = '') { if (!extension_loaded('apc') && !extension_loaded('apcu')) { throw new \RuntimeException('Unable to use APC(u) cache as APC(u) extension is not enabled.'); } parent::__construct($prefix); }
/** * @param string $prefix * @throws \RuntimeException */ public function __construct($prefix = '') { if (!extension_loaded('xcache')) { throw new \RuntimeException('Unable to use XCache cache as XCache extension is not enabled.'); } parent::__construct($prefix); }
/** * Constructor. * * @param array $options Array of options. */ public function __construct(array $options = null) { $options += array('directory' => sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'apix-cache'); parent::__construct(null, $options); if (!file_exists($this->getOption('directory')) || !is_dir($this->getOption('directory'))) { mkdir($this->getOption('directory'), 0755, true); } }
/** * @param \callable $callback * @param array $args * @param mixed $cacheKeySuffix * @return string */ protected function getCallbackCacheKey($callback, $args = array(), $cacheKeySuffix = null) { $key = parent::getCallbackCacheKey($callback, $args, $cacheKeySuffix); if (strpos($key, ' ') !== false) { $key = md5($key); } return $key; }
/** * Constructor. * * @param \PDO $pdo An instance of a PDO class. * @param array $options Array of options. */ public function __construct(\PDO $pdo, array $options = null) { // default options $this->options['db_table'] = 'cache'; $this->options['serializer'] = 'php'; // none, php, igBinary, json. $pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); parent::__construct($pdo, $options); $this->setSerializer($this->options['serializer']); // Initialises the database. $this->adapter->exec($this->getSql('init')); }
/** * Constructor. * * @param array|\Traversable|null $mix * @param array|null $options An array of user options. */ public function __construct($mix = null, array $options = null) { if (null === $mix) { $this->items = new \ArrayObject(); } else { if (is_array($mix) || $mix instanceof \Traversable) { $this->items = $mix; } else { throw new \Apix\Cache\Exception("Error Processing Request"); } } parent::__construct(null, $options); }
/** * Constructor. Sets the Mongo DB adapter. * * @param \MongoClient $Mongo A \MongoClient instance. * @param array $options Array of options. */ public function __construct(\MongoClient $Mongo, array $options = null) { // default options $this->options['db_name'] = 'apix'; $this->options['collection_name'] = 'cache'; $this->options['object_serializer'] = 'php'; // null, php, json, igBinary. // Set the adapter and merge the user+default options parent::__construct($Mongo, $options); $this->db = $this->adapter->selectDB($this->options['db_name']); $this->collection = $this->db->createCollection($this->options['collection_name'], false); $this->collection->ensureIndex(array('key' => 1), array('unique' => true, 'dropDups' => true)); // Using MongoDB TTL collections (MongoDB 2.2+) $this->collection->ensureIndex(array('expire' => 1), array('expireAfterSeconds' => 1)); $this->setSerializer($this->options['object_serializer']); }
/** * Constructor. * * @param \PDO $pdo An instance of a PDO class. * @param array $options Array of options. */ public function __construct(\PDO $pdo, array $options = null) { // default options $this->options['db_table'] = 'cache'; // table to hold the cache $this->options['serializer'] = 'php'; // null, php, igBinary, json $this->options['preflight'] = true; // wether to preflight the DB $this->options['timestamp'] = 'Y-m-d H:i:s'; // timestamp db format $pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); parent::__construct($pdo, $options); $this->setSerializer($this->options['serializer']); if ($this->options['preflight']) { $this->initDb(); } }
/** * Constructor. * * @param \Memcached $Memcached A Memcached instance. * @param array $options Array of options. */ public function __construct(\Memcached $memcached, array $options = null) { // default options $this->options['prefix_key'] = 'key_'; // prefix cache keys $this->options['prefix_tag'] = 'tag_'; // prefix cache tags $this->options['prefix_idx'] = 'idx_'; // prefix cache indexes $this->options['prefix_nsp'] = 'nsp_'; // prefix cache namespaces $this->options['serializer'] = 'php'; // none, php, json, igBinary. parent::__construct($memcached, $options); $memcached->setOption(\Memcached::OPT_COMPRESSION, false); if ($this->options['tag_enable']) { $memcached->setOption(\Memcached::OPT_BINARY_PROTOCOL, false); $this->setSerializer($this->options['serializer']); $this->setNamespace($this->options['prefix_nsp']); } }
/** * @param string $key * @return string */ protected function cacheKey($key) { $key = parent::cacheKey($key); return "{$key}-{$this->nodeSchemaVersion}"; }
/** * @param \CouchbaseBucket $bucket * @param string $prefix * @throws \RuntimeException */ public function __construct(\CouchbaseBucket $bucket, $prefix = '') { $this->cache = $bucket; parent::__construct($prefix); }
/** * Sets up our Template Cache. * * @param array $cacheStores An array of CacheStoreInterface objects used to store the templates * @param string $templateCacheKeyPrefix The cacheKey to use. Default: 'tc' * @param int $defaultCacheTime The default cache time, in seconds. Default: 300 */ public function __construct(CacheStoreInterface $PrimaryCacheStore, $templateCacheKeyPrefix = 'tc', $defaultCacheTime = 300) { parent::__construct($PrimaryCacheStore, $templateCacheKeyPrefix); $this->defaultCacheTime = $defaultCacheTime; }
/** * Constructor. * * @param array $options Array of options. */ public function __construct(array $options = null) { $options += array('directory' => sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'apix-cache'); parent::__construct(null, $options); $this->initDirectories(); }
/** * @see AbstractRepository::purgeObject() */ public function purgeObject($id) { try { $this->api->m->purgeObject($id); $object = $this->cache->get($id); if ($object !== FALSE) { return $this->cache->delete($id); } } catch (RepositoryException $e) { // @todo chain exceptions here. throw $e; } }
/** * Constructs the FileCache object * * @param array $cacheStores An array of CacheStoreInterface objects that are used to store our data * @param string $fileCacheKeyPrefix The key-prefix used when storing the files. Default: 'fc' */ public function __construct(CacheStoreInterface $PrimaryCacheStore, $fileCacheKeyPrefix = 'fc') { parent::__construct($PrimaryCacheStore, $fileCacheKeyPrefix); }
/** * Destructor. * * @api */ public function __destruct() { parent::__destruct(); }
/** * Writes the cache value to all of our cache stores * * @param string $key The cache key to store * @param string $value The value of the cache item * * @return boolean True */ public function put($key, $value, $duration, $localOnly = false) { return parent::put($key, $value, $this->cacheExpiration); }
function __construct($identifier, $redis) { parent::__construct($identifier, $redis); $this->ttl = null; }
/** * Constructor. */ public function __construct(array $options = array()) { parent::__construct(null, $options); }
/** * @param \Memcache $memcache * @param string $prefix * @throws \RuntimeException */ public function __construct(\Memcache $memcache, $prefix = '') { $this->cache = $memcache; parent::__construct($prefix); }
public function __destruct() { $this->data = NULL; parent::__destruct(); }
/** * {@inheritdoc} */ public function setSerializer($serializer) { switch ($serializer) { // @codeCoverageIgnoreStart case 'igBinary': // igBinary is not always compiled on the host machine. $this->serializer = \Redis::SERIALIZER_IGBINARY; break; // @codeCoverageIgnoreEnd // @codeCoverageIgnoreEnd case 'json': // $this->serializer = \Redis::SERIALIZER_JSON; parent::setSerializer($serializer); break; case 'php': $this->serializer = \Redis::SERIALIZER_PHP; break; default: $this->serializer = \Redis::SERIALIZER_NONE; } }
/** * @param \Couchbase $couchbase * @param string $prefix * @throws \RuntimeException */ public function __construct(\Couchbase $couchbase, $prefix = '') { $this->cache = $couchbase; parent::__construct($prefix); }
/** * @param \Redis $redis * @param string $prefix * @throws \RuntimeException */ public function __construct(\Redis $redis, $prefix = '') { $this->cache = $redis; parent::__construct($prefix); }
public function __construct(array $args = []) { parent::__construct($args); $this->options->force('path'); $this->options['path'] = rtrim($this->options['path'], '/') . '/'; }