I am building a task module, to do time consuming jobs in background. A worker instance is constantly pooling redis db for a new task. However after first connection, somehow rediska (a php redis client) closes connection, and when I make query to db, it automatically creates a new connection using default settings. At this point new connection is not using the settings in the configuration. It is using hard coded default values. I don’t know why it is doing this but here is the solution.
Whenever you use a rediska key, explicitly tell the instance name you want to use.
$option = array("rediska"=>"use_this_instance_name");
$pointer = new Rediska_Key("job:$index:pointer",$option);
To define aforementioned rediska instance:
$options = array ( 'addToManager' => true, 'name' => "use_this_instance_name", 'namespace' => '', 'servers' => array( array( 'host' => Rediska_Connection::DEFAULT_HOST, 'port' => Rediska_Connection::DEFAULT_PORT, 'weight' => Rediska_Connection::DEFAULT_WEIGHT, 'db'=>2, 'persistent'=>TRUE, 'timeout'=>0 ) ) ); $redis = new Rediska($options);