_host = array_key_exists('host', $configs) ? $configs['host'] : $this->_host; $this->_port = array_key_exists('port', $configs) ? $configs['port'] : $this->_port; $this->_passwd = array_key_exists('passwd', $configs) ? $configs['passwd'] : $this->_passwd; $this->_redis = new \Redis(); $this->_redis->connect($this->_host, $this->_port); if (!empty($this->_passwd)) { $this->_redis->auth($this->_passwd); } } public function __destruct(){ $this->_redis = null; } private function rawcommand() { $args = func_get_args(); return call_user_func_array(array($this->_redis, 'rawCommand'), $args); } public function hget($key, $hash_key){ return $this->_redis->hGet($key, $hash_key); } public function hlen($key){ return $this->_redis->hLen($key); } public function hexists($key, $hash_key){ return $this->_redis->hExists($key, $hash_key); } public function hdel($key, $hash_key){ return $this->_redis->hDel($key, $hash_key); } public function hset($key, $hash_key, $value){ return $this->_redis->hSet($key, $hash_key, $value); } public function get($key){ return $this->_redis->get($key); } public function exists($key){ return $this->_redis->exists($key); } public function del($key){ return $this->_redis->del($key); } public function set($key, $value){ return $this->_redis->set($key, $value); } public function pexpire($key, $mill_sec){ return $this->_redis->pexpire($key, $mill_sec); } public function incrBy($key, $num){ return $this->_redis->incrby($key, $num); } public function setNxPx($key, $val, $mill_sec) { return $this->rawcommand('SET', $key, $val, 'NX', 'PX', $mill_sec); } public function execScript($script, $args, $num_keys) { return $this->_redis->eval($script, $args, $num_keys); } } ?>