AsyncMemoryCache 1.0.1
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 AsyncMemoryCache --version 1.0.1
NuGet\Install-Package AsyncMemoryCache -Version 1.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="AsyncMemoryCache" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="AsyncMemoryCache" Version="1.0.1" />
<PackageReference Include="AsyncMemoryCache" />
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 AsyncMemoryCache --version 1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: AsyncMemoryCache, 1.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.
#:package AsyncMemoryCache@1.0.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=AsyncMemoryCache&version=1.0.1
#tool nuget:?package=AsyncMemoryCache&version=1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
AsyncMemoryCache
A highly configurable cache that aims to improve upon IMemoryCache without relying on it as its backing store.
- Lightweight
- Strongly typed
- Configurable eviction behavior
- Configurable lifetime for cache entries
- Lazy construction of cache object
- Supports asynchronous factories
- Automatic disposal of expired cache entries
- Integration with Microsoft.Extensions.DependencyInjection
- Integration with Microsoft.Extensions.Logging
Usage
using AsyncMemoryCache;
ILoggerFactory loggerFactory = ...;
var cacheLogger = loggerFactory.CreateLogger<AsyncMemoryCache<string, TheClassToCache>>();
var cacheConfig = new AsyncMemoryCacheConfiguration<string, TheClassToCache>
{
EvictionBehavior = EvictionBehavior.Default // new DefaultEvictionBehavior(TimeProvider.System, TimeSpan.FromSeconds(45))
};
var cache = new AsyncMemoryCache<string, TheClassToCache>(cacheConfig, cacheLogger); // Logger is optional
// The factory is started here, will not block
var cacheEntity = cache.Add("theKey", async () =>
{
var createdObject = await ...;
await Task.Delay(1000);
return createdObject;
})
.WithSlidingExpiration(TimeSpan.FromHours(12));
// Will block here until the object is created
var theCachedObject = await cache["theKey"];
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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.
-
net8.0
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.0)
- Nito.AsyncEx.Coordination (>= 5.1.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 4.2.0 | 186 | 2/22/2025 |
| 4.1.0 | 156 | 11/13/2024 |
| 4.0.2 | 194 | 3/16/2024 |
| 4.0.1 | 155 | 3/16/2024 |
| 4.0.0 | 184 | 3/16/2024 |
| 3.4.0 | 163 | 3/9/2024 |
| 3.3.1 | 185 | 3/9/2024 |
| 3.3.0 | 158 | 3/9/2024 |
| 3.2.0 | 185 | 3/9/2024 |
| 3.1.0 | 205 | 2/16/2024 |
| 3.0.0 | 189 | 2/14/2024 |
| 2.0.2 | 190 | 2/12/2024 |
| 2.0.1 | 152 | 2/12/2024 |
| 2.0.0 | 154 | 2/9/2024 |
| 1.1.0 | 168 | 2/9/2024 |
| 1.0.10 | 174 | 2/4/2024 |
| 1.0.9 | 166 | 2/4/2024 |
| 1.0.8 | 187 | 2/4/2024 |
| 1.0.7 | 181 | 2/4/2024 |
| 1.0.6 | 149 | 2/4/2024 |
| 1.0.5 | 183 | 1/29/2024 |
| 1.0.4 | 166 | 1/29/2024 |
| 1.0.3 | 144 | 1/29/2024 |
| 1.0.2 | 172 | 1/29/2024 |
| 1.0.1 | 149 | 1/29/2024 |