-
Notifications
You must be signed in to change notification settings - Fork 115
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
[FEATURE] Group cache invalidation (cache regions) #294
Comments
Hi @codingaddicted , sorry for the delay. I'm working on adding tagging support, which would be even more powerful than regions. Will update as soon as there's something more concrete. |
Hi @jodydonetti, thank you for your feedback. I agree with you that tags would be even a more flexible solution than a single region, as they would allow you to link a single cache item to multiple "groups". This would be a turnkey point for your project. I’ll keep a close eye on how this evolves with great interest. |
Oh... that would be uber-super feature. We are developing a new version of our product. For now we use some in-house implementation of our own Our code with use-cases suffer and we need this badly. :) We will look forward for your continuation on this. 😸 |
Eh, I know but it's uber-super complex to do with the limited Now I'm on vacation, but when I come back I'll create an issue with the details there. |
@jodydonetti maybe event not possible... How is going? 😄 Checkout |
UPDATE: it is happening 🥳 Any help would be appreciated! |
Hi all, v2.0.0-preview-1 is out 🥳 🙏 Please, if you can try it out and let me know what you think, how it feels to use it or anything else really: your contribution is essential, thanks! |
Hi all, I still can't believe it but v2.0.0 is finally out 🎉 |
Problem
When you have a cache containing items grouped in some way (within the same cache instance), you may have the need to remove/invalidate them as a set and not by every single item key (you also may not have all their keys).
For example, if you are using cache for many elements within a container and you want to invalidate all of them in a single operation knowing the container identifier only.
In this cases you probably compose the cache key using a common prefix (the group id or something similar), but the supported invalidation/removal methods only work on specific key and they don't support a "starts with" logic for example.
Solution
Some other cache libraries support the concept of "region". When you set a cache entry, you can do it using the key only or a key/region pair. In this way all invalidation procedures can be easily done using the single key (obviously) and also using the region identifier, to remove all associated items.
Alternatives
An alternative solution (easier to achive, but more flexible for some aspects) solution could be supporting a startsWith/endsWith/contains (or even RegEx) logic on cache key on invalidation operations. In this way you can use prefixes to identify more then one item.
Example
Both solutions stand on an abstraction to handle region items keys, which need to be saved internally on every provider.
For example, in
MemoryCacheAccessor
, theSetEntry
method should manage something like this:On the other way, the
RemoveEntry
should beThe text was updated successfully, but these errors were encountered: