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

stueynet's avatar

When / how do expired cache items get deleted

When you add an item to the cache with an expiry date on it does it automatically get deleted eventually? If so how is this accomplished?

0 likes
9 replies
willvincent's avatar

@stueynet That package is a console command.

(Though, to be fair, it doesn't appear to work with anything newer than 5.1...)

d3xt3r's avatar

Most cache are LRU based. Items get deleted(evicted) as an when required, as an example, to free memory for new items. I don't think Laravel's disk(file) based cache has a eviction policy.

If using any other driver (apc/memcached/redis) they will have a built in eviction system, so you need not worry. For disk based cache, you can rely on commands/packages etc...

1 like
stueynet's avatar

Ah that's interesting. Ok. Might just suck it up and switch to redis.

jlrdw's avatar

I would have thought any modern framework would automatically purge cache from time to time especially laravel.

skiat's avatar

FYI .. just tried jdavidbakr/laravel-cache-garbage-collector now with laravel 5.4 and it works

Please or to participate in this conversation.