YiiRedis
YiiRedis copied to clipboard
Config-level connection for session (and cache?)
Hi,
I'd like to separate data in different databases, in particular sessions from data, say respectively into database 1 and 2.
I noticed you can instantiate any RedisEntity by specifying a connection, so in principle I can do that. However, I'd find more usable/less error prone to setup the default connection for data, and configure session to use another connection.
A proposal follows, please let me know if you'd like a pull request. E.
-
changes to ARedisSession.php
public $connection = null; /** * Initializes the application component. * This method overrides the parent implementation by checking if redis is available. */ public function init() { if ($this->connection !== null) $this->setConnection($this->connection); else $this->getConnection(); parent::init(); } - example of main/config.php ```php 'redis' => array( 'class' => 'ext.redis.ARedisConnection', 'hostname' => 'localhost', 'database' => 2, 'port' => 6379, ), 'redis-session' => array( 'class' => 'ext.redis.ARedisConnection', 'hostname' => 'localhost', 'database' => 1, 'port' => 6379, ), 'session' => array( 'class' => 'ext.redis.ARedisSession', 'connection' => 'redis-session', ),
Hi ecesena,
+1
I can't agree more. And should be different from CRedisCache also. If you specify the change proposal we can develop it together.
Best,
Otávio
+1. The same problem is in the ARedisStatePersister.php. That would be great, if you can provide pull request.