IL.InMemoryCacheProvider 1.3.0

dotnet add package IL.InMemoryCacheProvider --version 1.3.0                
NuGet\Install-Package IL.InMemoryCacheProvider -Version 1.3.0                
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="IL.InMemoryCacheProvider" Version="1.3.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add IL.InMemoryCacheProvider --version 1.3.0                
#r "nuget: IL.InMemoryCacheProvider, 1.3.0"                
#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 IL.InMemoryCacheProvider as a Cake Addin
#addin nuget:?package=IL.InMemoryCacheProvider&version=1.3.0

// Install IL.InMemoryCacheProvider as a Cake Tool
#tool nuget:?package=IL.InMemoryCacheProvider&version=1.3.0                

InMemory Cache Provider

  • Basic implementation of generic in-memory cache provider, based on Microsoft.Extensions.Caching.Memory.
  • Comes with set of useful thread safe extensions to get objects from cache or add them with factory.
  • Introduces several not supported by default methods, like IEnumerable<string> GetAllKeys() or void DeleteAll().
  • Supports tags on cache entries and eviction by tag.

Usage sample:

Register in DI with any container of your preference. Microsoft.Extensions.DependencyInjection will be used in this sample.

services.AddSingleton<ICacheProvider, InMemoryCacheProvider>();

class Test(ICacheProvider cacheProvider)
{

  void Foo(CancellationToken cancellationToken = default)
  {
    var cacheKey = "test";
    var cacheTags = ["test1", "test2"];
    var valueFromCache = cacheProvider.GetOrAdd(cacheKey,
                CacheValueFactory,
                tags: cacheTags,
                cacheCreationCondition: s => !string.IsNullOrEmpty(s),
                expirationOptions: new ExpirationOptions
                {
                    AbsoluteExpirationRelativeToNow = TimeSpan.FromMinutes(1),
                    AbsoluteExpiration = DateTimeOffset.Now.AddMinutes(10),
                    SlidingExpiration = TimeSpan.FromSeconds(30)
                },
                cancellationToken: cancellationToken);
  }

  private string CacheValueFactory() => return "test value";

}

Nuget

https://www.nuget.org/packages/IL.InMemoryCacheProvider/

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  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 is compatible.  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 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on IL.InMemoryCacheProvider:

Package Downloads
IL.RankedCache

Decorator for caching mechanism of your preference allowing to keep track of how many times each entry was accessed, including some manual and automated cleanup possibilities.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.3.0 416 4/5/2024
1.2.3 109 3/30/2024
1.2.2 75 3/30/2024
1.2.1 84 3/29/2024
1.2.0 93 3/28/2024
1.1.2 251 3/1/2024
1.1.1 238 1/16/2024
1.1.0 258 11/7/2023
1.0.4 105 11/6/2023
1.0.1 183 9/16/2023
1.0.0 123 9/15/2023