/**
  * @param Object $config
  */
 public function __construct($config)
 {
     parent::__construct($config);
     $this->memcache = rcube::get_instance()->get_memcache();
     $this->debug = $config->get('memcache_debug');
     if (!$this->memcache) {
         rcube::raise_error(array('code' => 604, 'type' => 'db', 'line' => __LINE__, 'file' => __FILE__, 'message' => "Failed to connect to memcached. Please check configuration"), true, true);
     }
     // register sessions handler
     $this->register_session_handler();
 }
Exemplo n.º 2
0
 /**
  * @param Object $config
  */
 public function __construct($config)
 {
     parent::__construct($config);
     // get db instance
     $this->db = rcube::get_instance()->get_dbh();
     // session table name
     $this->table_name = $this->db->table_name('session', true);
     // register sessions handler
     $this->register_session_handler();
     // register db gc handler
     $this->register_gc_handler(array($this, 'gc_db'));
 }
 /**
  * @param Object $config
  */
 public function __construct($config)
 {
     parent::__construct($config);
     // instantiate Redis object
     $this->redis = new Redis();
     if (!$this->redis) {
         rcube::raise_error(array('code' => 604, 'type' => 'session', 'line' => __LINE__, 'file' => __FILE__, 'message' => "Failed to find Redis. Make sure php-redis is included"), true, true);
     }
     // get config instance
     $hosts = $this->config->get('redis_hosts', array('localhost'));
     // host config is wrong
     if (!is_array($hosts) || empty($hosts)) {
         rcube::raise_error(array('code' => 604, 'type' => 'session', 'line' => __LINE__, 'file' => __FILE__, 'message' => "Redis host not configured"), true, true);
     }
     // only allow 1 host for now until we support clustering
     if (count($hosts) > 1) {
         rcube::raise_error(array('code' => 604, 'type' => 'session', 'line' => __LINE__, 'file' => __FILE__, 'message' => "Redis cluster not yet supported"), true, true);
     }
     foreach ($hosts as $host) {
         // explode individual fields
         list($host, $port, $database, $password) = array_pad(explode(':', $host, 4), 4, null);
         // set default values if not set
         $host = $host !== null ? $host : '127.0.0.1';
         $port = $port !== null ? $port : 6379;
         $database = $database !== null ? $database : 0;
         if ($this->redis->connect($host, $port) === false) {
             rcube::raise_error(array('code' => 604, 'type' => 'session', 'line' => __LINE__, 'file' => __FILE__, 'message' => "Could not connect to Redis server. Please check host and port"), true, true);
         }
         if ($password != null && $this->redis->auth($password) === false) {
             rcube::raise_error(array('code' => 604, 'type' => 'session', 'line' => __LINE__, 'file' => __FILE__, 'message' => "Could not authenticate with Redis server. Please check password."), true, true);
         }
         if ($database != 0 && $this->redis->select($database) === false) {
             rcube::raise_error(array('code' => 604, 'type' => 'session', 'line' => __LINE__, 'file' => __FILE__, 'message' => "Could not select Redis database. Please check database setting."), true, true);
         }
     }
     // register sessions handler
     $this->register_session_handler();
 }
 /**
  * @param Object $config
  */
 public function __construct($config)
 {
     parent::__construct($config);
 }