Exemplo n.º 1
0
 /**
  * {@inheritdoc}
  *
  * Additional options:
  *  "client"   => the instance of \Predis\Client object
  *
  * @codeCoverageIgnore
  * @param  array                     $options
  * @throws \Endeveit\Cache\Exception
  */
 public function __construct(array $options = array())
 {
     if (!array_key_exists('client', $options) || !$options['client'] instanceof Client) {
         throw new Exception('You must provide option "client" with \\Predis\\Client object');
     }
     parent::__construct($options);
 }
Exemplo n.º 2
0
 /**
  * {@inheritdoc}
  *
  * Additional options:
  *  "client"   => the instance of \Memcache object
  *  "compress" => boolean value which indicates to enable zlib compression or not
  *
  * @codeCoverageIgnore
  * @param  array                     $options
  * @throws \Endeveit\Cache\Exception
  */
 public function __construct(array $options = array())
 {
     if (!array_key_exists('client', $options)) {
         throw new Exception('You must provide option "client" with \\Memcache object');
     }
     if (array_key_exists('compress', $options) && $options['compress']) {
         $options['compress'] = MEMCACHE_COMPRESSED;
     }
     parent::__construct($options);
     $this->validateIdentifier($this->getOption('prefix_id'));
     $this->validateIdentifier($this->getOption('prefix_tag'));
 }
Exemplo n.º 3
0
 /**
  * {@inheritdoc}
  *
  * Additional options:
  *  "local_cache_size" => the size of local cache
  *  "servers"          => array with connections parameters
  *                        array(
  *                          array('host' => '127.0.0.1', 'port' => 6379, 'timeout' => 0.0, 'weight' => 2),
  *                          array('host' => '127.0.0.1', 'port' => 6380, 'timeout' => 0.0, 'weight' => 1),
  *                          array('host' => '127.0.0.1', 'port' => 6381, 'timeout' => 0.0, 'weight' => 1),
  *                        )
  *
  * @codeCoverageIgnore
  * @param  array                     $options
  * @throws \Endeveit\Cache\Exception
  */
 public function __construct(array $options = array())
 {
     if (array_key_exists('local_cache_size', $options)) {
         $this->localCacheSize = intval($options['local_cache_size']);
         unset($options['local_cache_size']);
     }
     if (!array_key_exists('servers', $options) || !is_array($options['servers'])) {
         throw new Exception('You must provide option "servers" with array of connections parameters');
     }
     parent::__construct($options);
     foreach ($this->getOption('servers') as $server) {
         if (!array_key_exists('host', $server)) {
             throw new Exception('You must provide host in connection parameters');
         }
         $this->addConnection($server['host'], array_key_exists('port', $server) ? intval($server['port']) : self::DEFAULT_PORT, array_key_exists('timeout', $server) ? floatval($server['timeout']) : self::DEFAULT_TIMEOUT, array_key_exists('weight', $server) ? intval($server['weight']) : self::DEFAULT_WEIGHT);
     }
 }