0

I connected the slave redis, what a silly mistake -_-!!!

The learn is that we should always check server status before jumping into client code .

I'm trying to use redis in a php app, as google result, I choose phpredis. I established the connection, successfully got redis info by $this->_redis->info(), but failed to set any value. here are some software info:

php : 5.5.19 x64 thread safe

framework : CodeIgniter(sorry I don't know where to get version info)

redis : 2.8.15

phpredis : php_redis-2.2.7-5.5-ts-vc11-x64

And a helper class contains connection configuration and functions

class Redis_Module{
    private $_redis;
    function __construct(){     
        $this->ci = & get_instance();
        $redis_connection_array = $this->ci->config->item('redis_connection_array');
        $this->_redis = new Redis();
        $this->_redis->connect($redis_connection_array['host'],$redis_connection_array['port']);
        $this->_redis->auth($redis_connection_array['password']);
    }
    function info(){
        return $this->_redis->info();
    }
    function get($key){
        return $this->_redis->get($key);
    }
    function set($key, $value){
        return $this->_redis->set($key, $value);
    }
}

When I call these 3 functions, I can successfully get redis info, but both set('foo', 'bar') and get('foo') functions return false, especially get('an_existing_key') returns correct info cached in redis.

$redis_client = new Redis_Module();
$msg1 = $redis_client->set('foo', 'bar');
$msg2 = $redis_client->get("foo");
$msg3 = $redis_client->get("an_existing_key");
$msg4 = $redis_client->info();

I'm not familiar with php so am I missing any critical config or anything else?

Luffy
  • 99
  • 1
  • 10

0 Answers0