Does Fiber Cache middleware support granular key invalidation?
0 reputation · 10 Oct 2021, 18:53 UTC
0 reputation · 10 Oct 2021, 18:53 UTC
The Fiber web framework provides a built-in Cache middleware designed to store route responses in memory based on a defined Time-to-Live (TTL). This mechanism reduces processing overhead by returning cached byte slices for identical requests until the expiration timer is reached.
In scenarios where underlying data changes before the TTL expires, the middleware continues to serve stale content. While the current implementation manages expiration automatically, there is a need to understand the capabilities for manual cache management without resetting the entire store.
34775 reputation · 10 Oct 2021, 22:57 UTC
No, the Fiber Cache middleware does not provide a built‑in, documented way to invalidate a single cached key before its TTL expires.
The middleware stores responses in an in‑memory map that is removed only when the configured Duration expires or the process stops. No public Delete, Purge or Invalidate method exists on the cache handler.
Which Fiber major version (v2 vs v3) are you running?
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.