I'm very new to Redis and fairly new to Laravel so could use some pointers on this.
We have a legacy PHP application that stores sessions to Redis and I'm able to see it in Redis with the default naming convention, ie.: PHPREDIS_SESSION:1bd9ca87f5b606a35891c807857c2fde
We're moving towards a Laravel API framework and as a short-term hybrid solution we want the API layer to be able to recognize and work with the session that's already been created through the legacy application.
I've been making slow progress into understanding Redis and I can see the legacy system's entries in Redis from Laravel (if I connect with a blank prefix), but is there a way to cut through Laravel's specialized handling and have it load the same PHPREDIS_SESSION
space?
I've orbited this so many times I'm wondering if I've missed something simple.
CodePudding user response:
In config/cache.php
the prefix of the key is defined to be:
env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_') . '_cache')
So you should just be able to change your .env
file's CACHE_PREFIX
variable to the value of your choosing.
CodePudding user response:
Ultimately I got this working simply by updating my .env
file with:
REDIS_PREFIX=PHPREDIS_SESSION:
CACHE_PREFIX=
I was hoping to avoid that since it's kind of bleh, but it functions and I suppose a config file is better than forcing Laravel to act against the grain.
Laravel is now recognizing the session being stored by my legacy application and trying to load it. Now I just need to get de/serialization to sync...