You can get config variable like
$prefix = config('cache.stores.redis.session.prefix');
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hello guys,
I have been testing a new way to do prefix for Sessions and Cache using REDIS I tried creating new driver and many different other functionalities... and all defaulted to the same issue.
\Illuminate\Cache\CacheManager
protected function getPrefix(array $config)
{
return Arr::get($config, 'prefix') ?: $this->app['config']['cache.prefix'];
}
All I needed actually is this to not get the cache prefix from the config/cache.php prefix variable... But actually get it from the connection since it says it actually supports but it's not supporting this at all.
'redis' => [
'client' => 'predis',
'default' => [
'host' => env('REDIS_HOST', '127.0.0.1'),
'password' => env('REDIS_PASSWORD', null),
'port' => env('REDIS_PORT', 6379),
'database' => 0,
'prefix' => ''
],
'session' => [
'host' => env('REDIS_HOST', 'localhost'),
'password' => env('REDIS_PASSWORD', null),
'port' => env('REDIS_PORT', 6379),
'prefix' => 'redis_session',
'database' => 1,
]
],
The prefix on those connections is never been called or set. Anywhere for the connection...
Any ideas how I can force to set those?
Thanks,
Please or to participate in this conversation.