Exemplo n.º 1
0
 /**
  * Constructor
  *
  * @param \PDO $dbh
  * @param array $options
  */
 public function __construct(\PDO $dbh, array $options = [])
 {
     $this->dbh = $dbh;
     $this->dbh->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_SILENT);
     if (isset($options['table'])) {
         $this->table = (string) $options['table'];
     }
     if (isset($options['automatic_clean'])) {
         $this->automaticClean = (int) $options['automatic_clean'];
     }
     parent::__construct($options);
 }
Exemplo n.º 2
0
 /**
  * Constructor
  *
  * @param array $options
  * @throws Exception\CacheException
  */
 public function __construct(array $options = [])
 {
     if (!extension_loaded('xcache')) {
         throw new Exception\CacheException('XCache extension must be loaded.');
     }
     if (!ini_get('xcache.cacher') || ini_get('xcache.var_size') <= 0) {
         throw new Exception\CacheException('XCache extension is disabled.');
     }
     if (ini_get('xcache.admin.enable_auth')) {
         throw new Exception\CacheException('Is required set "xcache.admin.enable_auth" to "Off" in php.ini.');
     }
     parent::__construct($options);
 }
Exemplo n.º 3
0
 /**
  * Constructor
  *
  * @param array $options
  * @throws Exception\CacheException
  */
 public function __construct(array $options = [])
 {
     if (!extension_loaded('apcu')) {
         throw new Exception\CacheException('APCu extension must be loaded.');
     }
     $enabled = ini_get('apc.enabled');
     if (PHP_SAPI == 'cli') {
         $enabled = ini_get('apc.enable_cli');
         ini_set('apc.use_request_time', 0);
     }
     if (!$enabled) {
         throw new Exception\CacheException('APCu extension is disabled.');
     }
     parent::__construct($options);
 }
Exemplo n.º 4
0
 /**
  * Constructor
  *
  * @param array $options
  * @throws \InvalidArgumentException
  */
 public function __construct(array $options)
 {
     if (!isset($options['directory']) || !is_string($options['directory'])) {
         throw new \InvalidArgumentException('Missing option "directory"');
     }
     if (!is_dir($options['directory']) && !@mkdir($options['directory'], 0777, true)) {
         throw new \InvalidArgumentException(sprintf('Cache directory "%s" does not exist and could not be created', $options['directory']));
     }
     if (!is_writable($options['directory'])) {
         throw new \InvalidArgumentException(sprintf('The directory "%s" is not writable', $options['directory']));
     }
     $this->directory = rtrim($options['directory'], DIRECTORY_SEPARATOR);
     if (isset($options['directory_level'])) {
         $directoryLevel = (int) $options['directory_level'];
         if ($directoryLevel > 0) {
             $this->directoryLevel = $directoryLevel;
         }
     }
     if (isset($options['file_suffix'])) {
         $this->fileSuffix = (string) $options['file_suffix'];
     }
     parent::__construct($options);
 }
Exemplo n.º 5
0
 /**
  * Constructor
  *
  * @param \Memcached $memcached
  * @param array $options
  */
 public function __construct(\Memcached $memcached, array $options = [])
 {
     $this->memcached = $memcached;
     parent::__construct($options);
 }