Reputation: 41300
Laravel 8 has config file config\session.php
this file has 2 parameters to store
'driver' => env('SESSION_DRIVER', 'file'),
and
'store' => env('SESSION_STORE', null)
Both can be "apc"
, "dynamodb"
, "memcached"
, "redis"
The only difference I see is that 'driver' can also be "file"
, "cookie"
, "database"
, "array"
Please tell me what is the difference and why do we have 2 parameters there?
Upvotes: 0
Views: 1585
Reputation: 1029
a bit late but I noticed this today. It appears that Laravel uses a cache in sessions, so the SESSION_STORE is this cache store thing. If you go to cache config file you'll see these stores. So is to define an specific cache store of the cache config file. This is independent from the SESSION_DRIVER and SESSION_CONNECTION (database config file connection)
Upvotes: 0
Reputation: 2401
Essentially, it allows you to configure a separate CACHE_STORE
from your SESSION_STORE
.
Imagine you have APIv1 where you are caching queries using encrypted cache keys in Redis along with caching your User Sessions also in Redis.
Let's say you want to rollout APIv2 and want to clear all of your cached queries but not Log all of your users out.
If you're CACHE_STORE
and SESSION_STORE
are the same instance of a Redis Store you can not run php artisan cache:clear
without clearing both stores. And hunting down all of the encrypted cache keys you want to clear would be very difficult and time consuming.
However, if you setup your User Sessions on a separate Redis Store you can run it with confidence.
This is an example of why someone would use CACHE_STORE
or SESSION_STORE
, each of which can be pointed to separate Redis Database/Instances that you have configured in config/database.php
.
Upvotes: 3