Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

hillcow's avatar

Redis Key Eviction Policy with Laravel

I use Redis for cache, queues and sessions:

CACHE_DRIVER=redis
QUEUE_CONNECTION=redis
SESSION_DRIVER=redis

I recently noticed that my Redis instance thus uses 10.5GB of allocated memory. With a wopping 19.000.000 keys and 9.000.000.000 dataset bytes, which seems an awful lot.

As a response, I decided to set a limit of 500mb and "lru" policy:

maxmemory 500mb
maxmemory-policy allkeys-lru

Now the problem with this is that the users of my site got logged out of their account after some time. So I guess their session got deleted based on the "lru" policy - which I do not understand. I got logged out as well and I visit the website very, very frequently. So either there is something bad going on and the 500mb get filled up very quickly, or for some reason, accessing the website does not read the session and thus, the Redis key is not moved to the queue head and is lost at the tail at some point.

What do you think? What does your Redis configuration for your Laravel application look like? Do you allow more "maxmemory"? Do you use a different eviction policy?

Cheers

0 likes
0 replies

Please or to participate in this conversation.