EasyMemoryCache 3.0.7

dotnet add package EasyMemoryCache --version 3.0.7
                    
NuGet\Install-Package EasyMemoryCache -Version 3.0.7
                    
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="EasyMemoryCache" Version="3.0.7" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="EasyMemoryCache" Version="3.0.7" />
                    
Directory.Packages.props
<PackageReference Include="EasyMemoryCache" />
                    
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 EasyMemoryCache --version 3.0.7
                    
#r "nuget: EasyMemoryCache, 3.0.7"
                    
#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 EasyMemoryCache@3.0.7
                    
#: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=EasyMemoryCache&version=3.0.7
                    
Install as a Cake Addin
#tool nuget:?package=EasyMemoryCache&version=3.0.7
                    
Install as a Cake Tool

EasyMemoryCache

Build status

.NET Component to easily implement MemoryCache (sync and async) for your .NET Core Application

How to Use:

Open Package Manager Console and run:

Install-Package EasyMemoryCache

Usage:

First, register the component in your Application:

.AddEasyCache(new CacheSettings() { ... })

.NET Core Console Example

//setup our DI
var serviceProvider = new ServiceCollection()
    .AddEasyCache(new CacheSettings() { ... })
    .BuildServiceProvider();

var caching = serviceProvider.GetService<ICaching>();
return caching;

ASP.NET Core Example (Startup.cs)

services.AddEasyCache(Configuration.GetSection("CacheSettings").Get<CacheSettings>());

Configuration example: (Redis)

"CacheSettings": {
    "CacheProvider": "Redis",
    "IsDistributed": true,
    "RedisConnectionString": "localhost:6379,password=xxx=,ssl=False,abortConnect=False"
  }

For MemoryCache

 "IsDistributed": false,
 "CacheProvider": "MemoryCache",

InMemory cache will be used instead of Redis

Then inject the interface where do you want to use, for example:

private readonly ICaching _caching;
private string UserKeyCache => "UserKey";

public UserService(ICaching caching)
{
     _caching = caching;
}

Async:

var lstStringFromAsync = await _caching.GetOrSetObjectFromCacheAsync(CacheKeyNameForAsync, 20, ReturnListOfStringAsync);

With parameters:

var lstStringFromAsync = await _caching.GetOrSetObjectFromCacheAsync(CacheKeyNameForAsync, 20, () => ReturnListOfStringAsync(param));

Sync:

var lstString = _caching.GetOrSetObjectFromCache(CacheKeyName, 20, ReturnListOfString);

Check the code sample in the src directory

Product 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 is compatible.  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 is compatible.  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 EasyMemoryCache:

Package Downloads
AlertHawk.Monitoring.Domain

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
3.0.7 71 3/21/2026
3.0.6 593 1/21/2026
3.0.5 1,317 11/13/2025
3.0.4 3,470 6/5/2025
3.0.3 631 4/22/2025
3.0.2 3,513 12/21/2024
3.0.1 401 12/3/2024
3.0.0 764 11/19/2024
2.0.9 1,702 10/13/2024
2.0.8 1,517 9/13/2024
2.0.7 1,456 8/21/2024
2.0.6 317 8/12/2024
2.0.5 584 7/30/2024
2.0.4 2,092 6/21/2024
2.0.3 1,706 4/11/2024
2.0.2 1,867 2/7/2024
2.0.1 1,085 1/15/2024
2.0.0 1,001 12/25/2023
1.0.35 13,363 11/3/2023
1.0.34 1,996 8/13/2023
Loading failed

.NET 10 support