EasyMemoryCache 2.0.6

There is a newer version of this package available.
See the version list below for details.
dotnet add package EasyMemoryCache --version 2.0.6
                    
NuGet\Install-Package EasyMemoryCache -Version 2.0.6
                    
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="2.0.6" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="EasyMemoryCache" Version="2.0.6" />
                    
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 2.0.6
                    
#r "nuget: EasyMemoryCache, 2.0.6"
                    
#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.
#addin nuget:?package=EasyMemoryCache&version=2.0.6
                    
Install as a Cake Addin
#tool nuget:?package=EasyMemoryCache&version=2.0.6
                    
Install as a Cake Tool

EasyMemoryCache

Build status

NuGet alternate text is missing from this package README image

.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 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 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 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 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.4 391 6/5/2025
3.0.3 445 4/22/2025
3.0.2 2,540 12/21/2024
3.0.1 280 12/3/2024
3.0.0 655 11/19/2024
2.0.9 1,407 10/13/2024
2.0.8 826 9/13/2024
2.0.7 1,345 8/21/2024
2.0.6 229 8/12/2024
2.0.5 207 7/30/2024
2.0.4 1,907 6/21/2024
2.0.3 1,475 4/11/2024
2.0.2 1,414 2/7/2024
2.0.1 841 1/15/2024
2.0.0 894 12/25/2023
1.0.35 8,520 11/3/2023
1.0.34 1,867 8/13/2023
1.0.33 5,384 5/6/2023
1.0.32 195 5/5/2023
1.0.31 2,175 2/27/2023
1.0.30 274 2/24/2023
1.0.29 270 2/24/2023
1.0.28 288 2/24/2023
1.0.27 2,323 12/9/2022
1.0.26 684 11/28/2022
1.0.25 1,882 10/21/2022
1.0.24 5,720 3/30/2022
1.0.23 460 3/24/2022
1.0.22 489 3/21/2022
1.0.21 472 3/21/2022
1.0.20 1,601 1/19/2022
1.0.19 498 1/18/2022
1.0.18 486 1/18/2022
1.0.17 436 12/8/2021
1.0.16 1,315 7/13/2021
1.0.15 1,643 2/18/2021
1.0.14 595 2/10/2021
1.0.13 456 1/30/2021
1.0.12 387 1/30/2021
1.0.11 383 1/30/2021
1.0.10 2,589 8/1/2020
1.0.9 492 8/1/2020
1.0.8 1,928 12/18/2019
1.0.7 764 9/24/2019
1.0.6 959 7/18/2019
1.0.5 627 7/17/2019
1.0.4 603 7/17/2019
1.0.3 636 7/17/2019
1.0.2 612 7/17/2019
1.0.1 597 7/17/2019
1.0.0 656 7/15/2019

.NET 9 support + Performance improvements