nitro icon indicating copy to clipboard operation
nitro copied to clipboard

Actively gc cache entries with ttl on supported storage backends

Open pi0 opened this issue 1 year ago • 1 comments

Context: Followup from a discussion with @Atinux as he asked if it is possible to pass custom transaction options to defineCachedHandlerto allow setItem with custom ttl and allow invalidating caches. currently, some unstorage drivers support ttl inconsistently.


Currently, the caching layer, passively (on demand) invalidates cache entries on the next access. But it does not delete them during revalidation or in the background.

Actively (automatically by storage backend) invalidating caches, is pending for universal ttl support, which afterward, we can set it.

We might also find a strategy for passive invalidation (during revalidation if it fails for example) but not sure. Another option is for unstorage to support background gc.

pi0 avatar Apr 18 '24 09:04 pi0

I imagine the plan is to pass maxAge (if, for example swr: false) as the ttl for that setItem right?

sandros94 avatar Oct 21 '24 18:10 sandros94

https://github.com/nitrojs/nitro/pull/2783 adds maxAge to the underlying storage backend. I think next steps to increase support (and also to the passive mode for unsupported ones) goes to the storage side.

pi0 avatar Jan 07 '25 17:01 pi0