I want to setup redis caching for our session and cache both using predis since we have a cluster setup.
I’m using yii2-redis with predis. I’m a little confused with the config options.
The docs mention that to use the Cache component with predis the config must be:
return [
//....
'components' => [
// ...
'redis' => [
'class' => 'yii\redis\predis\PredisConnection',
'parameters' => 'tcp://redis:6379',
// ...
],
'cache' => [
'class' => 'yii\redis\Cache',
],
'session' => [
'class' => 'yii\redis\Cache',
],
]
];
However i want to separate session and cache into different redis databases. Where do I place to the database => 0 statement in the session/cache config ?
If i use the following i fear that the redis key will clash with the main redis config:
return [
//....
'components' => [
// ...
'redis' => [
'class' => 'yii\redis\predis\PredisConnection',
'parameters' => 'tcp://redis:6379',
// ...
],
'cache' => [
'class' => 'yii\redis\Cache',
'redis' => [
'database' => 1
]
],
...
]
];
Do i then separately configure the connections for session and cache and forego the main redis config on components ?
Tagging the project authors: @samdark