N
Nuxt4mo ago
dmarr

Is there a way to invalidate cache with wildcards?

I would like to have a route that does something like:
await useStorage('cache').removeItem(`nitro:functions:getData:*:*.json`);
await useStorage('cache').removeItem(`nitro:functions:getData:*:*.json`);
Is there any way I can use wildcards? Since my cache keys are dynamic, I'm not sure how I'd invalidate them. Thanks!
2 Replies
dmarr
dmarrOP4mo ago
it seems: storage.clear(); works, but I can't seem to send a path like nitro:functions:myFunc and have it remove everything below that
dmarr
dmarrOP4mo ago
posted over on anthony's discord that there are a couple open issues for this: https://github.com/unjs/unstorage/issues/336 https://github.com/unjs/unstorage/issues/396 -- I believe @pi0 commented that the broken behavior is what people expect right now and a fix would warrant a new version.
GitHub
Inconsistency between clear and getKeys · Issue #336 · unjs/unstora...
Environment [email protected], node v20.9.0 Reproduction Currently getKeys and clear behave differently when they are passed a prefix. const prefix = 'test'; let keys = await storage.getKeys(...
GitHub
getItems does not work with prefixStorage · Issue #396 · unjs/u...
Environment 1.10.1 Reproduction https://stackblitz.com/edit/stackblitz-starters-rrstqp?file=index.js Describe the bug Working useStorage().getItems(['namespace:key']) Not Working prefixStor...
Want results from more Discord servers?
Add your server