CacheManager
CacheManager copied to clipboard
Support for tagged cache items using multiple tags (multiple "regions")?
The API currently has a notion of a cache "region", which is a convenient way to group related cache entries so I can evict them using that region. But I have a scenario where I would like to be able to assign multiple regions (tags) to a cache item, so that I can evict all associated cache items by either Tag A or Tag B.
Is this something you think may be useful to have?
Hi @sfmskywalker, sure, that might be useful. But this would be very different than how Regions currently are implemented and I currently have no plans of implementing something like this.
Understood. I've seen such an implementation where a separate dictionary was being maintained, where each tag was a key, with the cache key as its value. This could probably be implemented as a separate class library, but I'll create a PR for your consideration.
I'd also have a lot of use for multiple tags. Consider a scenario where an aggregated sum of something consists of readings from multiple devices. The aggregated sum is handy to keep cached but when one of the devices in the aggregation sends new data, the aggregated sum should be invalidated from cache and calculated on the next request or by eventing as the invalidation has happened.
@sfmskywalker are you still working on the PR? I'd be happy to help.
@mkontula I haven't started yet, and it doesn't look like I will be needing this myself anytime soon. Please feel free to take it on.