aurawindsurfing's avatar

CACHE_DRIVER=array

I switched to array as file driver and database driver do not support cache tagging for this package: https://github.com/rappasoft/laravel-authentication-log

What is the difference between array/file/database apart from the obvious?

Is there any reason I should not use array?

I do not cache anything in my app and user logins are sessions and not cache...

0 likes
10 replies
krisi_gjika's avatar

"I do not cache anything in my app and user logins are sessions and not cache" - so why do you care about the cache driver?

aurawindsurfing's avatar

@krisi_gjika What I mean is that I do not Cache:: anything manually in my app but that package required change to array just wondering if anyone can tell me the difference between the array and file, where is array stored, in memory?

tykus's avatar
tykus
Best Answer
Level 104

@aurawindsurfing the array cache driver is an in-memory PHP array that lasts the duration only of the current Request. It is "persisted" in the Illuminate\Cache\ArrayStore class

1 like
piljac1's avatar

@tykus It actually lasts until the application's process shuts down. In a standard Laravel setup, a request is pretty much equivalent to an application process though. However, if you have Laravel Octane set up, the behavior changes. The array cache will now live until you restart the Octane server (because it keeps the application instance in memory).

piljac1's avatar

@aurawindsurfing It's a temporary cache. It is often used for unit tests or to avoid executing the same heavy query or logic multiple times during the same request.

krisi_gjika's avatar

@tykus also should be noted that other instances of the application, other requests, jobs, commands, can't access that "cache", since that memory does not belong to them.

Please or to participate in this conversation.