Ejemplo n.º 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);
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 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);
     }
 }
Ejemplo n.º 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());
 }
Ejemplo n.º 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'));
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 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']);
 }
Ejemplo n.º 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();
     }
 }
Ejemplo n.º 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']);
     }
 }
Ejemplo n.º 10
0
 /**
  * @param \Redis $redis
  * @param string $prefix
  * @throws \RuntimeException
  */
 public function __construct(\Redis $redis, $prefix = '')
 {
     $this->cache = $redis;
     parent::__construct($prefix);
 }
Ejemplo n.º 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;
 }
Ejemplo n.º 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();
 }
Ejemplo n.º 13
0
 /**
  * @param \CouchbaseBucket $bucket
  * @param string $prefix
  * @throws \RuntimeException
  */
 public function __construct(\CouchbaseBucket $bucket, $prefix = '')
 {
     $this->cache = $bucket;
     parent::__construct($prefix);
 }
Ejemplo n.º 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;
 }
Ejemplo n.º 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();
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 17
0
 function __construct($identifier, $redis)
 {
     parent::__construct($identifier, $redis);
     $this->ttl = null;
 }
Ejemplo n.º 18
0
 /**
  * @param \Couchbase $couchbase
  * @param string $prefix
  * @throws \RuntimeException
  */
 public function __construct(\Couchbase $couchbase, $prefix = '')
 {
     $this->cache = $couchbase;
     parent::__construct($prefix);
 }
Ejemplo n.º 19
0
 /**
  * Constructor.
  *
  * @api
  */
 public function __construct()
 {
     parent::__construct();
 }
Ejemplo n.º 20
0
 /**
  * Constructor.
  */
 public function __construct(array $options = array())
 {
     parent::__construct(null, $options);
 }
Ejemplo n.º 21
0
 public function __construct()
 {
     parent::__construct();
     $this->data = [];
 }
Ejemplo n.º 22
0
 /**
  * @param \Memcached $memcached
  * @param string $prefix
  * @throws \RuntimeException
  */
 public function __construct(\Memcached $memcached, $prefix = '')
 {
     $this->cache = $memcached;
     parent::__construct($prefix);
 }
Ejemplo n.º 23
0
 public function __construct(array $args = [])
 {
     parent::__construct($args);
     $this->options->force('path');
     $this->options['path'] = rtrim($this->options['path'], '/') . '/';
 }