Skip to content

Config-level connection for session (and cache?) #17

Description

@0x0ece

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',
    ),

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions