IL.InMemoryCacheProvider 1.2.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package IL.InMemoryCacheProvider --version 1.2.1
                    
NuGet\Install-Package IL.InMemoryCacheProvider -Version 1.2.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="IL.InMemoryCacheProvider" Version="1.2.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="IL.InMemoryCacheProvider" Version="1.2.1" />
                    
Directory.Packages.props
<PackageReference Include="IL.InMemoryCacheProvider" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add IL.InMemoryCacheProvider --version 1.2.1
                    
#r "nuget: IL.InMemoryCacheProvider, 1.2.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.
#:package IL.InMemoryCacheProvider@1.2.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=IL.InMemoryCacheProvider&version=1.2.1
                    
Install as a Cake Addin
#tool nuget:?package=IL.InMemoryCacheProvider&version=1.2.1
                    
Install as a Cake Tool

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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.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.4.0 527 4/8/2025
1.3.0 2,093 4/5/2024
1.2.3 159 3/30/2024
1.2.2 125 3/30/2024
1.2.1 134 3/29/2024
1.2.0 145 3/28/2024
1.1.2 542 3/1/2024
1.1.1 289 1/16/2024
1.1.0 300 11/7/2023
1.0.4 145 11/6/2023
1.0.1 231 9/16/2023
1.0.0 181 9/15/2023