v2.0.0-preview-2
Pre-releaseImportant
This is a 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.
🔀 New entry options to precisely skip read/write on memory/distributed levels
New entry options have been added to precisely skip reading and/or writing for both the memory (L1) and the distributed (L2) levels.
Now we have 4 options with more granular control:
SkipMemoryCacheRead
SkipMemoryCacheWrite
SkipDistributedCacheRead
SkipDistributedCacheWrite
Previously we had 2 options:
SkipMemoryCache
SkipDistributedCache
Now these 2 old ones now act in this way:
- the setter changes both the corresponding read/write ones
- the getter returns
true
if both the read and the write options are set totrue
(eg:return SkipMemoryCacheRead && SkipMemoryCacheWrite
)
Even if they work, to avoid future confusion the 2 old ones have been marked as [Obsolete]
.
Of course the handy ext methods like SetSkipMemoryCache()
still work.
📜 New IncludeTagsInLogs
option
FusionCache now allows you to include tags when logging a cache entry, via the new IncludeTagsInLogs
option.
It is disabled by default since tags can be considered as part of the "content" of the cached entry itself, an so they may contain sensitive informations.
We can just enable it in the FusionCacheOptions
and be good to go.
⬇️ Other release notes from preview-1 ⬇️
🏷️ 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.