mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
Need a way to set a default query cache TTL #5888
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Dadibom on GitHub (Feb 16, 2018).
Originally assigned to: @Ocramius on GitHub.
I need to clear the query cache weekly to prevent redis from overflowing, as there's no TTL by default. I've looked for ways to set a global/default TTL but haven't found a way.
Willing to attempt a PR if someone gives me some pointers, I'm not sure where to begin with this one.
@Ocramius commented on GitHub (Feb 16, 2018):
TTL is per-query by design. If some queries are cached indefinitely, then the cleanup task is on your side.
@Dadibom commented on GitHub (Feb 16, 2018):
All queries are cached indefinitely, which is a huge problem. I've set a TTL on query builders to prevent this very issue but the cache still keeps growing at very fast rates (many gb per week). The biggest problem is that we use a (very sensible) redis eviction policy that will evict keys with TTL, but not without it, which means that eventually everything but doctrines query cache will be lost before the server finally just starts ignoring new writes.
I think it'd make a lot of sense to add a default ttl, even if it's very long (like, a month or two?) because this is a problem that I don't think most people will notice until it's too late.
@Ocramius commented on GitHub (Feb 16, 2018):
Check https://redis.io/topics/lru-cache
@Dadibom commented on GitHub (Feb 16, 2018):
Yeah I'm using a volatile eviction policy, which I don't think is that uncommon