Hi,All
I have a question #########How to select number of database for Redis in Phalcon framework?#########
Firstly,I can use follow code to connect Redis server.
$di = new \Phalcon\DI\FactoryDefault();
$di->setShared('redis', function (){
$redis = new \Redis();
$redis->connect("localhost");
$redis->select(1); // I need use no. 1 database of Redis
return $redis;
});
Anywhere In controller file,I can use the variable($this->redis) to 'get' or 'set' Redis data! of course,I can use method named 'select' to change number of database.
$this->redis->select(2);
Howover
In the Phalcon framework,I can use follow code to define redis connection!
$frontCache = new \Phalcon\Cache\Frontend\Data([
'lifetime' => -1
]);
$config = [
'host' => '127.0.0.1',
'port' => 6379,
];
$redis = new \Phalcon\Cache\Backend\Redis($frontCache, $config);
But,it seems that the class '\Phalcon\Cache\Backend\Redis' didn't has options and methods to connect other database of Redis!