bentocache icon indicating copy to clipboard operation
bentocache copied to clipboard

Missing expireByTag method

Open yss14 opened this issue 10 months ago • 2 comments

While reading up on the topic of tags, I noticed that there doesn't appear to be an expireByTag method available.

Is there a particular reason for its absence? Is such a method planned for a future release, or is there a recommended alternative approach?

yss14 avatar Apr 16 '25 08:04 yss14

Hey, yeah we could totally add that, maybe I’m being a bit naive rn but it shouldn’t be too complicated

There are probably some workarounds in the meantime, but it kinda depends on what you're trying to do. Can you explain a bit your issue ? Might not be ideal depending on your use case, but you could just disable grace for now ?

Julien-R44 avatar Apr 20 '25 19:04 Julien-R44

@Julien-R44 We’re planning to integrate bentocache into our microservices architecture, using SWR-style caching with a soft timeout of 1ms and grace period enabled.

As an enhancement, it would be nice to have the ability to immediately mark cached entries as expired when we receive a create/update/delete operation related to a specific resource. Leveraging the existing tagging system for this purpose would be significantly more convenient than explicitly invalidating individual cache keys.

Additionally, our preference is to expire the affected entries rather than removing them entirely from the cache using deleteByTags. This approach would allow us to preserve stale data for a short time window, enabling background revalidation while avoiding unnecessary cache misses.

yss14 avatar Apr 22 '25 08:04 yss14