Hello,
I am using persistent connections, as well as several redis databases. I have found that the value returned by 'getDBNum()' to be wrong if the connection was at a non-0 value previous to being handed the already used socket.
The following example code:
$serverip = '127.0.0.1';
$redis = new Redis();
$redis->pconnect($serverip, null, 3);
if ($redis->getDBNum() !== 0)
{
$redis->select(0);
}
$redis->set('test', 'test');
$redis->select(1);
$redis->set('test', 'test2');
$redis->close();
$redis->pconnect($serverip, null, 3);
if ($redis->getDBNum() !== 0)
{
$redis->select(0);
}
$redis->set('test', 'test');
$redis->select(1);
$redis->set('test', 'test2');
$redis->close();
shows the following in the redis-cli monitor:
1391120777.554788 [0 127.0.0.1:59846] "SET" "test" "test"
1391120777.555127 [0 127.0.0.1:59846] "SELECT" "1"
1391120777.555377 [1 127.0.0.1:59846] "SET" "test" "test2"
1391120777.555596 [1 127.0.0.1:59846] "SET" "test" "test"
1391120777.555829 [1 127.0.0.1:59846] "SELECT" "1"
1391120777.556033 [1 127.0.0.1:59846] "SET" "test" "test2"
(There should be a "select 0" after the second "set test")
If the persistent connection chooses to create a new connection however, it works as intended as the dbnum defaults to 0.
Hello,
I am using persistent connections, as well as several redis databases. I have found that the value returned by 'getDBNum()' to be wrong if the connection was at a non-0 value previous to being handed the already used socket.
The following example code:
shows the following in the redis-cli monitor:
(There should be a "select 0" after the second "set test")
If the persistent connection chooses to create a new connection however, it works as intended as the dbnum defaults to 0.