Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Problem with setting own Redis database name
  • Hi.
    My cache on redis works fine.
    But when I set my own name for redis db 
    in app/config/cache.php:
    'redis'  => array(
    'database'  => 'myname'  
    ),

    and in app/cache/db.php

        'redis' => array(
            'myname' => array(
                'hostname'  => '127.0.0.1',
                'port'      => 6379,
                'timeout' => null,
            )
        ),

    it's still working with default base.

  • what is app/cache/db.php?

    app/config/<your environment>/db.php I hope you mean?
  • Sorry, I mean 'app/config/db.php'
  • if you change it in there, then probably your default values in the environment db file will overwrite it.

    Never add anything in a global config file unless it is valid for all environments. And if so, make sure an environment config will not overwrite it.
  • ok, I move it to config/development/db.php:

    return array(
    'default' => array(
    'connection'  => array(
    'dsn'        => 'mysql:host=localhost;dbname=mysqlb',
    'username'   => 'uname',
    'password'   => 'pass',
    ),
            //'profiling'  => true,
    ),

        'redis' => array(
            'myname' => array(
                'hostname'  => '127.0.0.1',
                'port'      => 6379,
                'timeout' => null,
            )
        ),
    );

    but redis still working with default base. Are there error in config?
  • Bug found.

    In fuel/core/classes/cache/storage/redis.php, in _validate_config(), the switch should read:

                case 'database':
                    // do we have a database config
                    if (empty($value) or ! is_string($value)) // this must be is_string() instead of is_array()
                    {
                        $value = 'default';
                    }
                break;

  • It seems to work.

    How I can delete separate base from redis now?

    I tried

    1. Cache::delete_all(); - in this case removed all bases
    2. Cache::delete_all('mybase', 'redis'); - not work
    3. 
    $redis = Redis::forge();
    $redis->flushdb();

    - also removed all bases
  • If you mean a specific key or set of keys, use

    Cache::delete('mybase');

    It will delete all keys starting with "mybase"...
  • thanks, all works

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion