bentocache icon indicating copy to clipboard operation
bentocache copied to clipboard

[Cache metadata] Allow to return cache metadata from getOrSet()

Open MarcLopezAvila opened this issue 3 months ago • 0 comments

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

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!

MarcLopezAvila avatar Oct 23 '25 21:10 MarcLopezAvila