Need a way to set a default query cache TTL #5888

Closed
opened 2026-01-22 15:21:18 +01:00 by admin · 4 comments
Owner

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.

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.
admin added the ImprovementWon't FixQuestion labels 2026-01-22 15:21:18 +01:00
admin closed this issue 2026-01-22 15:21:18 +01:00
Author
Owner

@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.

@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.
Author
Owner

@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.

@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.
Author
Owner

@Ocramius commented on GitHub (Feb 16, 2018):

Check https://redis.io/topics/lru-cache

@Ocramius commented on GitHub (Feb 16, 2018): Check https://redis.io/topics/lru-cache
Author
Owner

@Dadibom commented on GitHub (Feb 16, 2018):

Yeah I'm using a volatile eviction policy, which I don't think is that uncommon

@Dadibom commented on GitHub (Feb 16, 2018): Yeah I'm using a volatile eviction policy, which I don't think is that uncommon
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#5888