v2.0.0-preview-1
Pre-releaseImportant
This is the first PREVIEW of a very big and important milestone for FusionCache.
All help is more than welcome since the main feature, Tagging, is an uber complex beast.
Warning
Although all is already in a very good shape, this is still a PREVIEW version.
Warning
Because of the MAJOR version change, for now I decided to bump the wire format identifier: read more here and here.
🏷️ Tagging (docs)
Yep, it's true: FusionCache now has full support for tagging!
This means we can now associate one or more tags to any cache entry and, later on, simply call RemoveByTag("my-tag")
to evict all the entries that have the "my-tag"
associated to them.
And yes, it works with all the other features of FusionCache like L1+L2, backplane, fail-safe, soft timeouts, eager refresh, adaptive caching and everything else.
Honestly, the end result is a thing of beauty.
Here's an example:
cache.Set("risotto_milanese", 123, tags: ["food", "yellow"]);
cache.Set("kimchi", 123, tags: ["food", "red"]);
cache.Set("trippa", 123, tags: ["food", "red"]);
cache.Set("sunflowers", 123, tags: ["painting", "yellow"]);
// [...]
// REMOVE ENTRIES WITH TAG "red"
cache.RemoveByTag("red");
// NOW ONLY "risotto_milanese" and "sunflowers" ARE IN THE CACHE
// [...]
// REMOVE ENTRIES WITH TAG "food"
cache.RemoveByTag("food");
// NOW ONLY "sunflowers" IS IN THE CACHE
It's really that simple.
How to make it work, to make it work well, and to make it work in a scalable and flexible way including support for all the resiliency features of FusionCache (eg: fail-safe, auto-recovery, etc) that is a completely different thing.
If you want to know more read here for the proposal, including a complete overview of the design I decided to use for the feature, which I think strikes a delicate balance of all considerations.
And, if you like, let me know your thoughts!
🧼 Clear() (docs)
Thanks to the underlying usage of the aforementioned Tagging, it is also now possible for FusionCache to support a proper Clear()
method, something that the community has been asking for a long time.
And this, too, works with everything else like cache key prefix, backplane notifications, auto-recovery and so on.
Here's an example:
cache.Set("foo", 1);
cache.Set("bar", 2);
cache.Set("baz", 3);
// CLEAR
cache.Clear();
// NOW THE CACHE IS EMPTY
Easy peasy.
For more read here for the design behind it, more details and some performance considerations.
And, if you like, let me know your thoughts!
⚠️ Breaking Changes
Since this is a MAJOR version change (v1
-> v2
) there have been multiple binary breaking changes.
Having said that, unless someone somehow decided to re-implement FusionCache itself, a simple package update + full recompile should do the trick, since thanks to overloads and whatnot all the existing code should work as before (and, in case that is not the case, please let me know!).
📕 Docs
The docs have not been updated yet with Tagging or Clear() support, but will be done in time for the official v2.0.0
release.