Releases: ZiggyCreatures/FusionCache
v0.1.4
📞 Events (more)
FusionCache now has a comprehensive set of events to subscribe to, so you can be notified of core events when they happen.
Example:
// SUBSCRIBE TO CACHE MISS EVENTS
cache.Events.Miss += (s, e) => {
// REACT TO THE EVENT HERE, WITH THE RELATED CACHE KEY AVAILABLE VIA e.Key
};
This is also a stepping stone towards the next step: plugins (#15).
And thanks to @JoeShook for the invaluable help!
🚀 Performance
Added some perf optimizations.
v0.1.3
🤷 Introducing MaybeValue<T>
(more)
A new type has been introduced to model a value that may be there or not, just like the standard .NET nullables but for both reference and value types.
It supports implicit convesion to/from T
and is used in a couple of places (see below).
🕹️ Better TryGet[Async]
(more)
The TryGet[Async]
return type is now MaybeValue<T>
for better ease of use (more like the standard .NET nullables).
Example:
var maybeFoo = cache.TryGet<int>("foo");
if (maybeFoo.HasValue) {
// EXPLICIT ACCESS
var foo = maybeFoo.Value;
// OR IMPLICIT CONVERSION
int foo = maybeFoo;
}
🕹️ Better GetOrSet[Async]
(more)
The GetOrSet[Async]
methods now has an additional failSafeDefaultValue
param to handle factory failures (with fail-safe enabled) in case there's no expired/stale value to use (eg: cold start, first use, etc).
Example:
// WITH FAIL-SAFE ENABLED
cache.GetOrSet<int>("foo", _ => GetFooFromDb(), 42);
There's also a new GetOrSet[Async]
overload available that accepts a value directly instead of a factory: this covers the cases when you already have a default value to use so you don't have to allocate a useless lambda.
Example:
// BEFORE
cache.GetOrSet<int>("foo", _ => 42);
// FROM v0.1.3
cache.GetOrSet<int>("foo", 42);
⚠️ Breaking changes
The TryGet[Async]
methods now returns a MaybeValue<T>
instead of a TryGetResult<T>
.
This new type also contains the Success
prop present in the old TryGetResult<T>
type, but marked as [Obsolete]
to better ease the transition.
Also, the old TryGetResult<T>
type is still there, in case you've used that somewhere, but the type as a whole has been marked as [Obsolete]
to warn of the usage.
The only case of an actual breaking change is if you were doing something like this:
// USING IMPLICIT bool CONVERSION
if (cache.TryGet<int>("foo")) {
[...]
}
but it should have been rare, since the value would have been discarded.
Anyway, in that case, you simply have to do this now:
if (cache.TryGet<int>("foo").HasValue) {
[...]
}
or, even better:
var maybeFoo = cache.TryGet<int>("foo");
if (maybeFoo.HasValue) {
// EXPLICIT ACCESS
var foo = maybeFoo.Value;
// OR IMPLICIT CONVERSION
int foo = maybeFoo;
}
🚀 Performance
Optimized cpu and memory usage so that common scenarios will consume less resources.
v0.1.2
v0.1.1
💫 More flexible type handling
Better support for caching flows with flexible types.
Previously, doing this:
var data = (object)42;
cache.Set("foo", data);
cache.GetOrDefault<int>("foo");
would not have resulted in getting back 42
.
Thanks to type inference the Set
method call in the 2nd line in reality is a Set<object>
and this, in addition to various internal details to support advanced features (fail-safe, etc), made it incompatible to transparently swich from one type to the other.
Now this scenario is fully supported 🎉
⚠️ Namespace change
The first and last namespace change: the general namespace changed from ZiggyCreatures.FusionCaching
to ZiggyCreatures.Caching.Fusion
.
The fix should be very easy: update the packages, compile, see where it fails and change a couple of using
s, that's it.
Sorry for this hassle 🙏 , it will be the last time.
🚀 Performance
Optimized cpu and memory usage so that common scenarios will consume less resources.
v0.1.0
Initial release.
Almost all the main features currently planned are there, with tests, documentation and whatnot.