-
-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tagging system #53
Comments
Super happy to see this issue. Allow me to propose a mechanism that I believe is universal for any kind o production system: https://github.com/mcollina/async-cache-dedupe#invalidation. It's actually quite similar to the tags you illustrated, except that in the proposed solution the Suppose I have a That's impossible to tell with static |
Yup absolutely, I should have included it in my first comment. In fact, the tags will be compatible with the adaptive caching system we have today. So : const product = await bento.getOrSet({
key: 'product:1',
factory: async (ctx) => {
const product = await getFromDb(1)
ctx.setTags(product.categories.map((category) => category.name))
return product
}
}); Lemme know if it could suit you |
Beautiful 😍 I believe that solves my last trouble with the library, and would make bentocache the ultimate caching library for production-grade node apps! In fact, such API should be sufficient to implement an automatic ORM caching layer similar to https://github.com/Suor/django-cacheops. Basically, all relations returned by the ORM are saved as references, and all updates/deletes automatically invalidate relevant results. Possibly, |
I merged PR #57, which adds experimental support for tags 🎉 Next steps:
Still not sure if we should deprecated namespace. Lemme know if you have any thoughts Also @wodCZ and @dunhamjared thanks a lot for the sponsorship 🙏 |
1.2.0 released with docs Release notes : https://github.com/Julien-R44/bentocache/releases/tag/bentocache%401.2.0 If you encounter any bugs with tagging or have any feedback, please let me know! |
Creating an issue in case people have the same question.
I am not fully happy with the namespace system we have. Not enough for easy invalidation. So I would love to have tags and it's planned, but it's quite a tricky thing to nail down, especially in bentocache, where we have a lot of different features
I've been doing quite a bit of research on the topic and should try an implementation when I have some time. The API will be super simple:
Then, we could delete all entries tagged with
tag-1
using:This would remove all entries that have the
tag-1
tag.It's likely that this tagging system will deprecate the current namespace system we have. I think they would become useless once we have tags. We would keep namespaces until v2, but they would be marked as deprecated via JSDoc
The text was updated successfully, but these errors were encountered: