IL.InMemoryCacheProvider
1.2.2
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package IL.InMemoryCacheProvider --version 1.2.2
NuGet\Install-Package IL.InMemoryCacheProvider -Version 1.2.2
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.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add IL.InMemoryCacheProvider --version 1.2.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: IL.InMemoryCacheProvider, 1.2.2"
#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.2.2 // Install IL.InMemoryCacheProvider as a Cake Tool #tool nuget:?package=IL.InMemoryCacheProvider&version=1.2.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
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()
orvoid 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
Product | Versions 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.
-
net6.0
- IL.Misc (>= 1.0.4)
- Microsoft.Extensions.Caching.Memory (>= 6.0.0)
-
net7.0
- IL.Misc (>= 1.0.4)
- Microsoft.Extensions.Caching.Memory (>= 7.0.0)
-
net8.0
- IL.Misc (>= 1.0.4)
- Microsoft.Extensions.Caching.Memory (>= 8.0.0)
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.