Example #1
0
 /**
  * driver initialisation
  *
  * @access	public
  * @return	void
  */
 public function init()
 {
     // generic driver initialisation
     parent::init();
     if ($this->redis === false) {
         // get the redis database instance
         $this->redis = \Redis_Db::instance($this->config['database']);
     }
 }
Example #2
0
 public function __construct($identifier, $config)
 {
     parent::__construct($identifier, $config);
     $this->config = isset($config['redis']) ? $config['redis'] : array();
     // make sure we have a redis id
     $this->config['cache_id'] = $this->_validate_config('cache_id', isset($this->config['cache_id']) ? $this->config['cache_id'] : 'fuel');
     // check for an expiration override
     $this->expiration = $this->_validate_config('expiration', isset($this->config['expiration']) ? $this->config['expiration'] : $this->expiration);
     // make sure we have a redis database configured
     $this->config['database'] = $this->_validate_config('database', isset($this->config['database']) ? $this->config['database'] : 'default');
     if (static::$redis === false) {
         // get the redis database instance
         try {
             static::$redis = \Redis_Db::instance($this->config['database']);
         } catch (\Exception $e) {
             throw new \FuelException('Can not connect to the Redis engine. The error message says "' . $e->getMessage() . '".');
         }
         // get the redis version
         preg_match('/redis_version:(.*?)\\n/', static::$redis->info(), $info);
         if (version_compare(trim($info[1]), '1.2') < 0) {
             throw new \FuelException('Version 1.2 or higher of the Redis NoSQL engine is required to use the redis cache driver.');
         }
     }
 }