bentocache
bentocache copied to clipboard
[Cache metadata] Allow to return cache metadata from getOrSet()
It would be extremely helpful if getOrSet() could return not only the cached value but also basic metadata, for example: creation time, expiration time, and whether the result was a hit, miss, stale, or refreshed.
Why
- To easily generate proper HTTP caching headers such as ETag, Age, Last-Modified, and Cache-Status.
- To report cache status (MISS, HIT, STALE, REFRESHED) in API responses without having to call getEntry() again.
- To avoid redundant cache lookups and logic when building observability or cache debugging tools.
Is there a way to retrieve this information right now with the current methods? We want to use this library in our microservices but this is a blocker.
Thanks!