bnomei / kirby3-redis-cachedriver

Redis based Cache-Driver
MIT License
6 stars 0 forks source link

Setting `bnomei.redis-cachedriver.host` has no effect #1

Closed neildaniels closed 4 years ago

neildaniels commented 4 years ago

I'm trying to set a different default Redis hostname, but I get an error saying "Connection refused" and shows the default (unchanged) hostname. Similar issue with port.

config.php

return [
    'cache' => [
        'pages' => [
            'active' => true,
            'type' => 'redis',
        ],
    ],
    'bnomei.redis-cachedriver.host' => 'redis',
]
Screen Shot 2020-03-24 at 6 30 39 PM

Current workaround is to simply specify the host in the specific cache:

return [
    'cache' => [
        'pages' => [
            'active' => true,
            'type' => 'redis',
            'host' => 'redis',
        ],
    ],
]
bnomei commented 4 years ago

all kirby options must be complete arrays. sadly there is no auto-magical merging. so for the pages cache its just like the readme states:

site/config/config.php with callbacks

return [
'cache' => [
'pages' => [
'active' => true,
'type' => 'redis', // <!-- this will trigger the plugin to be used
'host' => function() { return env('REDIS_HOST'); }, // <--- in array but not from plugin option, since plugin is used a callback will work.
'port' => function() { return env('REDIS_PORT'); },
'database' => function() { return env('REDIS_DATABASE'); },
'password' => function() { return env('REDIS_PASSWORD'); },
'prefix' => 'pages',
'ignore' => function ($page) {
return $page->id() === 'something';
}
]
],
];
bnomei commented 4 years ago

@neildaniels i think there is also the merging order to be considered. currently the plugin will apply the plugin options first as default and merge the actual settings on top of this.

https://github.com/bnomei/kirby3-redis-cachedriver/blob/master/classes/Redis.php#L25

this is necessary so different caches could use different options. i do not think there is a way to support this and fix the issue you experienced both at the same time.

non the less i will check props again asap. so i am leaving this issue open again in the meantime.

bnomei commented 4 years ago

found the issue. will fix today.