VLobyntsev.FluentCaching 0.0.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package VLobyntsev.FluentCaching --version 0.0.1
NuGet\Install-Package VLobyntsev.FluentCaching -Version 0.0.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="VLobyntsev.FluentCaching" Version="0.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add VLobyntsev.FluentCaching --version 0.0.1
#r "nuget: VLobyntsev.FluentCaching, 0.0.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install VLobyntsev.FluentCaching as a Cake Addin
#addin nuget:?package=VLobyntsev.FluentCaching&version=0.0.1

// Install VLobyntsev.FluentCaching as a Cake Tool
#tool nuget:?package=VLobyntsev.FluentCaching&version=0.0.1

Code samples

Configure caching policy by entity and build cache object


var cache = new CacheBuilder()
.For<User>(u => u.UseAsKey("user").CombinedWith(u => u.Id) // alternatively UseAsKey(u => $"user{u.Id}")
                .And().SetExpirationTimeoutTo(2).Minutes.And(10).Seconds
                .With().SlidingExpiration())
.Build();

Add object to cache

var user = _userService.GetUserById(42);

await cache.CacheAsync(user);

Retrieve object from cache

var userId = 42;

await cache.RetrieveAsync<User>(userId);

Remove object from cache

var userId = 42;

await cache.RemoveAsync<User>(userId);

Multi property configuration is supported with the same set of features

var cache = new CacheBuilder()
.For<User>(u => u.UseAsKey(u => u.FirstName).CombinedWith(u => u.LastName) // alternatively UseAsKey(u => u.FirstName + u.LastName)
                .And().SetExpirationTimeoutTo(2).Minutes.And(10).Seconds
                .With().SlidingExpiration())
.Build();

var userKey = new {FirstName = "John", LastName = "Doe"}; // may be any class or struct with corresponding properties
await cache.RetrieveAsync<User>(userKey);

Different cache implementations for different entities are supported

var cache = new CacheBuilder()
.For<User>(u => u.UseAsKey(u => u.FirstName).CombinedWith(u => u.LastName)
                .And().SetExpirationTimeoutTo(2).Minutes.And(10).Seconds
                .With().AbsoluteExpiration().And().StoreInMemory())
.For<Order>(o => o.UseAsKey(o => o.Date).CombinedWith("order")
                .And().SetInfiniteExpirationTimeout()
                .And().StoreInDistributedCache())
.Build();

Current benchmarks


BenchmarkDotNet=v0.12.1, OS=Windows 10.0.19045
Intel Core i5-9300H CPU 2.40GHz, 1 CPU, 8 logical and 4 physical cores
.NET Core SDK=7.0.202
  [Host]     : .NET Core 6.0.9 (CoreCLR 6.0.922.41905, CoreFX 6.0.922.41905), X64 RyuJIT
  DefaultJob : .NET Core 6.0.9 (CoreCLR 6.0.922.41905, CoreFX 6.0.922.41905), X64 RyuJIT


Method ItemsCount Mean Error StdDev Median Allocated
CacheWithComplexKey 100 0.3616 ms 0.0455 ms 0.1340 ms 0.3616 ms 53.72 KB
RetrieveWithComplexKey 100 0.0924 ms 0.0018 ms 0.0027 ms 0.0919 ms 47.27 KB
CacheWithSimpleKey 100 0.0821 ms 0.0051 ms 0.0148 ms 0.0736 ms 48.13 KB
RetrieveWithSimpleKey 100 0.0656 ms 0.0013 ms 0.0015 ms 0.0652 ms 38.75 KB
CacheWithComplexKey 1000 1.0152 ms 0.0473 ms 0.1349 ms 0.9603 ms 530.86 KB
RetrieveWithComplexKey 1000 1.0323 ms 0.0519 ms 0.1522 ms 0.9536 ms 476.17 KB
CacheWithSimpleKey 1000 0.9037 ms 0.0436 ms 0.1251 ms 0.8571 ms 484.06 KB
RetrieveWithSimpleKey 1000 0.6686 ms 0.0088 ms 0.0078 ms 0.6677 ms 390.32 KB
CacheWithComplexKey 10000 14.1614 ms 0.4543 ms 1.2437 ms 13.6662 ms 5382.46 KB
RetrieveWithComplexKey 10000 10.6172 ms 0.5431 ms 1.5139 ms 9.8729 ms 4835.57 KB
CacheWithSimpleKey 10000 12.1970 ms 0.2404 ms 0.5713 ms 12.0789 ms 4845.48 KB
RetrieveWithSimpleKey 10000 6.8092 ms 0.1594 ms 0.4471 ms 6.6842 ms 3905.95 KB
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

    • No dependencies.

NuGet packages (3)

Showing the top 3 NuGet packages that depend on VLobyntsev.FluentCaching:

Package Downloads
VLobyntsev.FluentCaching.DependencyInjection

Microsoft.Extensions.DependencyInjection integration for fluent caching

VLobyntsev.FluentCaching.Memory

Memory cache integration for fluent caching

VLobyntsev.FluentCaching.DistributedCache

Distributed cache integration for fluent caching

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.0.5 133 3/5/2024
0.0.4 78 3/5/2024
0.0.3 125 1/30/2024
0.0.2 184 7/18/2023
0.0.1 325 7/28/2021