Пример #1
0
 /**
  * @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);
 }
Пример #2
0
 /**
  * @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);
 }
Пример #3
0
 /**
  * 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);
     }
 }
Пример #4
0
 /**
  * Constructor.
  *
  * @param \Redis $redis   A Redis client instance.
  * @param array  $options Array of options.
  */
 public function __construct(\Redis $redis, array $options = null)
 {
     $options['atomicity'] = !isset($options['atomicity']) || true === $options['atomicity'] ? \Redis::MULTI : \Redis::PIPELINE;
     $this->options['serializer'] = 'php';
     // null, php, igBinary, json.
     parent::__construct($redis, $options);
     $this->setSerializer($this->options['serializer']);
     $redis->setOption(\Redis::OPT_SERIALIZER, $this->getSerializer());
 }
Пример #5
0
 /**
  * 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'));
 }
Пример #6
0
 /**
  * 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);
 }
Пример #7
0
 /**
  * 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']);
 }
Пример #8
0
 /**
  * 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();
     }
 }
Пример #9
0
 /**
  * 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']);
     }
 }
Пример #10
0
 /**
  * @param \Redis $redis
  * @param string $prefix
  * @throws \RuntimeException
  */
 public function __construct(\Redis $redis, $prefix = '')
 {
     $this->cache = $redis;
     parent::__construct($prefix);
 }
Пример #11
0
 /**
  * Creates a SystemCache instance
  *
  * @param CacheStoreInterface $PrimaryCacheStore    Primary cache store implementation
  * @param string         $systemCacheKeyPrefix  A prefix to use for the cache keys. This can be any string. Default: 'sc'
  * @param int            $systemCacheExpiration The duration for cache to live, in seconds. Default: 300
  */
 public function __construct(CacheStoreInterface $PrimaryCacheStore, $systemCacheKeyPrefix = 'sc', $systemCacheExpiration = 300)
 {
     parent::__construct($PrimaryCacheStore, $systemCacheKeyPrefix);
     $this->cacheExpiration = $systemCacheExpiration;
 }
Пример #12
0
 /**
  * @param CacheStoreInterface $PrimaryCacheStore
  * @param VersionService $VersionService
  * @param string $nodeSchemaVersion
  * @param bool $nodeCacheKeepLocal
  */
 public function __construct(CacheStoreInterface $PrimaryCacheStore, VersionService $VersionService, $nodeSchemaVersion = null, $nodeCacheKeepLocal = true)
 {
     parent::__construct($PrimaryCacheStore, 'nc', $nodeCacheKeepLocal);
     $this->VersionService = $VersionService;
     $this->nodeSchemaVersion = $nodeSchemaVersion ?: $this->VersionService->getSystemVersion();
 }
Пример #13
0
 /**
  * @param \CouchbaseBucket $bucket
  * @param string $prefix
  * @throws \RuntimeException
  */
 public function __construct(\CouchbaseBucket $bucket, $prefix = '')
 {
     $this->cache = $bucket;
     parent::__construct($prefix);
 }
Пример #14
0
 /**
  * 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;
 }
Пример #15
0
 /**
  * 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();
 }
Пример #16
0
 /**
  * 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);
 }
Пример #17
0
 function __construct($identifier, $redis)
 {
     parent::__construct($identifier, $redis);
     $this->ttl = null;
 }
Пример #18
0
 /**
  * @param \Couchbase $couchbase
  * @param string $prefix
  * @throws \RuntimeException
  */
 public function __construct(\Couchbase $couchbase, $prefix = '')
 {
     $this->cache = $couchbase;
     parent::__construct($prefix);
 }
Пример #19
0
 /**
  * Constructor.
  *
  * @api
  */
 public function __construct()
 {
     parent::__construct();
 }
Пример #20
0
 /**
  * Constructor.
  */
 public function __construct(array $options = array())
 {
     parent::__construct(null, $options);
 }
Пример #21
0
 public function __construct()
 {
     parent::__construct();
     $this->data = [];
 }
Пример #22
0
 /**
  * @param \Memcached $memcached
  * @param string $prefix
  * @throws \RuntimeException
  */
 public function __construct(\Memcached $memcached, $prefix = '')
 {
     $this->cache = $memcached;
     parent::__construct($prefix);
 }
Пример #23
0
 public function __construct(array $args = [])
 {
     parent::__construct($args);
     $this->options->force('path');
     $this->options['path'] = rtrim($this->options['path'], '/') . '/';
 }