4👍
It isn’t possible to purge expired entries as they expire. This is one of the many reasons you probably don’t want to use the database cache in production!
If possible, you should switch to a different cache backend (I prefer Redis). If you can’t, you do have a few other options:
-
If you know the cache keys you want to purge, you can use the low-level cache API to directly delete the keys you want to purge.
-
You could tweak the
MAX_ENTRIES
and/orCULL_FREQUENCY
cache arguments to limit the overall size of the cache. -
You could poke into the database directly (perhaps from a background task or cron job), manually running some SQL like
DELETE FROM cache_table WHERE expires < now()
(I haven’t tested this, but I think it should work).
Source:stackexchange.com