Microsoft.Extensions.Caching.Memory
9.0.4
Prefix Reserved
See the version list below for details.
dotnet add package Microsoft.Extensions.Caching.Memory --version 9.0.4
NuGet\Install-Package Microsoft.Extensions.Caching.Memory -Version 9.0.4
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="9.0.4" />
<PackageVersion Include="Microsoft.Extensions.Caching.Memory" Version="9.0.4" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" />
paket add Microsoft.Extensions.Caching.Memory --version 9.0.4
#r "nuget: Microsoft.Extensions.Caching.Memory, 9.0.4"
#addin nuget:?package=Microsoft.Extensions.Caching.Memory&version=9.0.4
#tool nuget:?package=Microsoft.Extensions.Caching.Memory&version=9.0.4
About
Provides implementations for local and distributed in-memory cache. It stores and retrieves data in a fast and efficient way.
Key Features
- A concrete implementation of the IMemoryCache interface, which represents a local in-memory cache that stores and retrieves data in a fast and efficient way
- A distributed cache that supports higher scale-out than local cache
- Expiration and eviction policies for its entries
- Entry prioritization for when the cache size limit is exceeded and needs to be compacted by entry eviction
- Track of cache statictics
How to Use
Use Microsoft.Extensions.Caching.Memory over System.Runtime.Caching when working with ASP.NET Core as it provides better integration support. For example, IMemoryCache works natively with ASP.NET Core dependency injection.
Local in-memory serialization:
using Microsoft.Extensions.Caching.Memory;
using MemoryCache cache = new(new MemoryCacheOptions());
object valueToCache = new();
string key = "key";
using (ICacheEntry entry = cache.CreateEntry(key))
{
// Entries are committed after they are disposed therefore it does not exist yet.
Console.WriteLine($"Exists: {cache.TryGetValue(key, out _)}\n");
entry.Value = valueToCache;
entry.SlidingExpiration = TimeSpan.FromSeconds(2);
}
bool exists = cache.TryGetValue(key, out object? cachedValue);
Console.WriteLine($"Exists: {exists}" );
Console.WriteLine($"cachedValue is valueToCache? {object.ReferenceEquals(cachedValue, valueToCache)}\n");
Console.WriteLine("Wait for the sliding expiration...");
Thread.Sleep(TimeSpan.FromSeconds(2));
Console.WriteLine("Exists: " + cache.TryGetValue(key, out _));
// You can also use the acceleration extensions to set and get entries
string key2 = "key2";
object value2 = new();
cache.Set("key2", value2);
object? cachedValue2 = cache.Get(key2);
Console.WriteLine($"cachedValue2 is value2? {object.ReferenceEquals(cachedValue2, value2)}");
Main Types
The main types provided by this library are:
Microsoft.Extensions.Caching.Memory.MemoryCache
Microsoft.Extensions.Caching.Memory.MemoryCacheOptions
Microsoft.Extensions.Caching.Distributed.MemoryDistributedCache
Microsoft.Extensions.Caching.Memory.MemoryDistributedCacheOptions
Additional Documentation
Related Packages
Microsoft.Extensions.Caching.Abstractions
Feedback & Contributing
Microsoft.Extensions.Caching.Memory is released as open source under the MIT license. Bug reports and contributions are welcome at the GitHub repository.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. 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 was computed. 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. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 is compatible. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.6.2
- Microsoft.Extensions.Caching.Abstractions (>= 9.0.4)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.4)
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.4)
- Microsoft.Extensions.Options (>= 9.0.4)
- Microsoft.Extensions.Primitives (>= 9.0.4)
- System.ValueTuple (>= 4.5.0)
-
.NETStandard 2.0
- Microsoft.Extensions.Caching.Abstractions (>= 9.0.4)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.4)
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.4)
- Microsoft.Extensions.Options (>= 9.0.4)
- Microsoft.Extensions.Primitives (>= 9.0.4)
-
net8.0
- Microsoft.Extensions.Caching.Abstractions (>= 9.0.4)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.4)
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.4)
- Microsoft.Extensions.Options (>= 9.0.4)
- Microsoft.Extensions.Primitives (>= 9.0.4)
-
net9.0
- Microsoft.Extensions.Caching.Abstractions (>= 9.0.4)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.4)
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.4)
- Microsoft.Extensions.Options (>= 9.0.4)
- Microsoft.Extensions.Primitives (>= 9.0.4)
NuGet packages (2.8K)
Showing the top 5 NuGet packages that depend on Microsoft.Extensions.Caching.Memory:
Package | Downloads |
---|---|
Microsoft.EntityFrameworkCore
Entity Framework Core is a modern object-database mapper for .NET. It supports LINQ queries, change tracking, updates, and schema migrations. EF Core works with SQL Server, Azure SQL Database, SQLite, Azure Cosmos DB, MySQL, PostgreSQL, and other databases through a provider plugin API. Commonly Used Types: Microsoft.EntityFrameworkCore.DbContext Microsoft.EntityFrameworkCore.DbSet |
|
Microsoft.EntityFrameworkCore.Relational
Shared Entity Framework Core components for relational database providers. |
|
Microsoft.Data.SqlClient
The current data provider for SQL Server and Azure SQL databases. This has replaced System.Data.SqlClient. These classes provide access to SQL and encapsulate database-specific protocols, including tabular data stream (TDS). Commonly Used Types: Microsoft.Data.SqlClient.SqlConnection Microsoft.Data.SqlClient.SqlException Microsoft.Data.SqlClient.SqlParameter Microsoft.Data.SqlClient.SqlDataReader Microsoft.Data.SqlClient.SqlCommand Microsoft.Data.SqlClient.SqlTransaction Microsoft.Data.SqlClient.SqlParameterCollection Microsoft.Data.SqlClient.SqlClientFactory When using NuGet 3.x this package requires at least version 3.4. |
|
Microsoft.EntityFrameworkCore.SqlServer
Microsoft SQL Server database provider for Entity Framework Core. |
|
Microsoft.EntityFrameworkCore.Design
Shared design-time components for Entity Framework Core tools. |
GitHub repositories (308)
Showing the top 20 popular GitHub repositories that depend on Microsoft.Extensions.Caching.Memory:
Repository | Stars |
---|---|
jellyfin/jellyfin
The Free Software Media System - Server Backend & API
|
|
bitwarden/server
Bitwarden infrastructure/backend (API, database, Docker, etc).
|
|
dotnet/efcore
EF Core is a modern object-database mapper for .NET. It supports LINQ queries, change tracking, updates, and schema migrations.
|
|
App-vNext/Polly
Polly is a .NET resilience and transient-fault-handling library that allows developers to express policies such as Retry, Circuit Breaker, Timeout, Bulkhead Isolation, and Fallback in a fluent and thread-safe manner. From version 6.0.1, Polly targets .NET Standard 1.1 and 2.0+.
|
|
abpframework/abp
Open-source web application framework for ASP.NET Core! Offers an opinionated architecture to build enterprise software solutions with best practices on top of the .NET. Provides the fundamental infrastructure, cross-cutting-concern implementations, startup templates, application modules, UI themes, tooling and documentation.
|
|
aspnetboilerplate/aspnetboilerplate
ASP.NET Boilerplate - Web Application Framework
|
|
Flow-Launcher/Flow.Launcher
:mag: Quick file search & app launcher for Windows with community-made plugins
|
|
JeffreySu/WeiXinMPSDK
微信全平台 .NET SDK, Senparc.Weixin for C#,支持 .NET Framework 及 .NET Core、.NET 8.0。已支持微信公众号、小程序、小游戏、微信支付、企业微信/企业号、开放平台、JSSDK、微信周边等全平台。 WeChat SDK for C#.
|
|
ThreeMammals/Ocelot
.NET API Gateway
|
|
MassTransit/MassTransit
Distributed Application Framework for .NET
|
|
elsa-workflows/elsa-core
A .NET workflows library
|
|
graphql-dotnet/graphql-dotnet
GraphQL for .NET
|
|
LykosAI/StabilityMatrix
Multi-Platform Package Manager for Stable Diffusion
|
|
aspnet/Mvc
[Archived] ASP.NET Core MVC is a model view controller framework for building dynamic web sites with clean separation of concerns, including the merged MVC, Web API, and Web Pages w/ Razor. Project moved to https://github.com/aspnet/AspNetCore
|
|
DotNetNext/SqlSugar
.Net aot ORM Fastest ORM DB2 Hana Simple Easy VB.NET Sqlite orm Oracle ORM Mysql Orm 虚谷数据库 postgresql ORm SqlServer oRm 达梦 ORM 人大金仓 ORM 神通ORM C# ORM , C# ORM .NET ORM NET5 ORM .NET6 ORM ClickHouse orm QuestDb ,TDengine ORM,OceanBase orm,GaussDB orm ,Tidb orm Object/Relational Mapping
|
|
ChilliCream/graphql-platform
Welcome to the home of the Hot Chocolate GraphQL server for .NET, the Strawberry Shake GraphQL client for .NET and Nitro the awesome Monaco based GraphQL IDE.
|
|
anjoy8/Blog.Core
💖 ASP.NET Core 8.0 全家桶教程,前后端分离后端接口,vue教程姊妹篇,官方文档:
|
|
umbraco/Umbraco-CMS
Umbraco is a free and open source .NET content management system helping you deliver delightful digital experiences.
|
|
immense/Remotely
A remote control and remote scripting solution, built with .NET 8, Blazor, and SignalR.
|
|
openiddict/openiddict-core
Flexible and versatile OAuth 2.0/OpenID Connect stack for .NET
|
Version | Downloads | Last updated | |
---|---|---|---|
10.0.0-preview.3.25171.5 | 2,288 | 4/10/2025 | |
10.0.0-preview.2.25163.2 | 6,285 | 3/18/2025 | |
10.0.0-preview.1.25080.5 | 9,945 | 2/25/2025 | |
9.0.4 | 948,254 | 4/8/2025 | |
9.0.3 | 3,383,433 | 3/11/2025 | |
9.0.2 | 5,058,813 | 2/11/2025 | |
9.0.1 | 6,904,963 | 1/14/2025 | |
9.0.0 | 17,789,113 | 11/12/2024 | |
9.0.0-rc.2.24473.5 | 564,886 | 10/8/2024 | |
9.0.0-rc.1.24431.7 | 242,256 | 9/10/2024 | |
9.0.0-preview.7.24405.7 | 345,616 | 8/13/2024 | |
9.0.0-preview.6.24327.7 | 244,373 | 7/9/2024 | |
9.0.0-preview.5.24306.7 | 84,296 | 6/11/2024 | |
9.0.0-preview.4.24266.19 | 77,484 | 5/21/2024 | |
9.0.0-preview.3.24172.9 | 194,240 | 4/11/2024 | |
9.0.0-preview.2.24128.5 | 89,112 | 3/12/2024 | |
9.0.0-preview.1.24080.9 | 112,078 | 2/13/2024 | |
8.0.1 | 56,330,573 | 10/8/2024 | |
8.0.0 | 152,264,909 | 11/14/2023 | |
8.0.0-rc.2.23479.6 | 1,433,247 | 10/10/2023 | |
8.0.0-rc.1.23419.4 | 361,993 | 9/12/2023 | |
8.0.0-preview.7.23375.6 | 450,891 | 8/8/2023 | |
8.0.0-preview.6.23329.7 | 205,146 | 7/11/2023 | |
8.0.0-preview.5.23280.8 | 184,154 | 6/13/2023 | |
8.0.0-preview.4.23259.5 | 144,889 | 5/16/2023 | |
8.0.0-preview.3.23174.8 | 230,361 | 4/11/2023 | |
8.0.0-preview.2.23128.3 | 208,207 | 3/14/2023 | |
8.0.0-preview.1.23110.8 | 141,216 | 2/21/2023 | |
7.0.0 | 151,427,134 | 11/7/2022 | |
7.0.0-rc.2.22472.3 | 245,904 | 10/11/2022 | |
7.0.0-rc.1.22426.10 | 248,379 | 9/14/2022 | |
7.0.0-preview.7.22375.6 | 113,561 | 8/9/2022 | |
7.0.0-preview.6.22324.4 | 81,933 | 7/12/2022 | |
7.0.0-preview.5.22301.12 | 70,062 | 6/14/2022 | |
7.0.0-preview.4.22229.4 | 83,041 | 5/10/2022 | |
7.0.0-preview.3.22175.4 | 80,480 | 4/13/2022 | |
7.0.0-preview.2.22152.2 | 88,914 | 3/14/2022 | |
7.0.0-preview.1.22076.8 | 74,897 | 2/17/2022 | |
6.0.3 | 1,425,881 | 11/12/2024 | |
6.0.2 | 2,540,342 | 10/8/2024 | |
6.0.1 | 239,670,471 | 2/8/2022 | |
6.0.0 | 120,483,756 | 11/8/2021 | |
6.0.0-rc.2.21480.5 | 519,658 | 10/12/2021 | |
6.0.0-rc.1.21451.13 | 275,800 | 9/14/2021 | |
6.0.0-preview.7.21377.19 | 100,845 | 8/10/2021 | |
6.0.0-preview.6.21352.12 | 49,864 | 7/14/2021 | |
6.0.0-preview.5.21301.5 | 190,279 | 6/15/2021 | |
6.0.0-preview.4.21253.7 | 88,125 | 5/24/2021 | |
6.0.0-preview.3.21201.4 | 101,842 | 4/8/2021 | |
6.0.0-preview.2.21154.6 | 74,308 | 3/11/2021 | |
6.0.0-preview.1.21102.12 | 368,450 | 2/12/2021 | |
5.0.0 | 184,377,392 | 11/9/2020 | |
5.0.0-rc.2.20475.5 | 386,760 | 10/13/2020 | |
5.0.0-rc.1.20451.14 | 326,423 | 9/14/2020 | |
5.0.0-preview.8.20407.11 | 205,223 | 8/25/2020 | |
5.0.0-preview.7.20364.11 | 119,148 | 7/21/2020 | |
5.0.0-preview.6.20305.6 | 59,157 | 6/25/2020 | |
5.0.0-preview.5.20278.1 | 6,616 | 6/10/2020 | |
5.0.0-preview.4.20251.6 | 202,282 | 5/18/2020 | |
5.0.0-preview.3.20215.2 | 119,258 | 4/23/2020 | |
5.0.0-preview.2.20160.3 | 113,296 | 4/2/2020 | |
5.0.0-preview.1.20120.4 | 62,396 | 3/16/2020 | |
3.1.32 | 7,075,615 | 12/13/2022 | |
3.1.31 | 1,364,947 | 11/8/2022 | |
3.1.30 | 1,184,146 | 10/11/2022 | |
3.1.29 | 1,609,013 | 9/13/2022 | |
3.1.28 | 954,838 | 8/9/2022 | |
3.1.27 | 972,497 | 7/12/2022 | |
3.1.26 | 773,880 | 6/14/2022 | |
3.1.25 | 1,265,075 | 5/10/2022 | |
3.1.24 | 867,545 | 4/11/2022 | |
3.1.23 | 1,639,029 | 3/8/2022 | |
3.1.22 | 5,164,547 | 12/14/2021 | |
3.1.21 | 3,664,237 | 11/7/2021 | |
3.1.20 | 2,205,402 | 10/11/2021 | |
3.1.19 | 2,755,666 | 9/14/2021 | |
3.1.18 | 5,766,587 | 8/10/2021 | |
3.1.17 | 2,423,090 | 7/13/2021 | |
3.1.16 | 3,625,991 | 6/8/2021 | |
3.1.15 | 3,722,159 | 5/11/2021 | |
3.1.14 | 4,680,793 | 4/6/2021 | |
3.1.13 | 5,747,787 | 3/9/2021 | |
3.1.12 | 3,937,578 | 2/9/2021 | |
3.1.11 | 6,698,848 | 1/12/2021 | |
3.1.10 | 12,768,292 | 11/9/2020 | |
3.1.9 | 17,256,351 | 10/13/2020 | |
3.1.8 | 34,495,988 | 9/8/2020 | |
3.1.7 | 16,988,129 | 8/11/2020 | |
3.1.6 | 18,118,963 | 7/14/2020 | |
3.1.5 | 18,005,529 | 6/9/2020 | |
3.1.4 | 21,070,728 | 5/12/2020 | |
3.1.3 | 32,497,631 | 3/24/2020 | |
3.1.2 | 15,860,686 | 2/18/2020 | |
3.1.1 | 25,219,794 | 1/14/2020 | |
3.1.0 | 43,951,279 | 12/3/2019 | |
3.1.0-preview3.19553.2 | 165,887 | 11/13/2019 | |
3.1.0-preview2.19525.4 | 32,738 | 11/1/2019 | |
3.1.0-preview1.19506.1 | 762,076 | 10/15/2019 | |
3.0.3 | 337,351 | 2/18/2020 | |
3.0.2 | 97,386 | 1/14/2020 | |
3.0.1 | 2,200,418 | 11/18/2019 | |
3.0.0 | 39,668,309 | 9/23/2019 | |
3.0.0-rc1.19456.10 | 47,196 | 9/16/2019 | |
3.0.0-preview9.19423.4 | 1,383,350 | 9/4/2019 | |
3.0.0-preview8.19405.4 | 407,323 | 8/13/2019 | |
3.0.0-preview7.19362.4 | 93,687 | 7/23/2019 | |
3.0.0-preview6.19304.6 | 179,403 | 6/12/2019 | |
3.0.0-preview5.19227.9 | 649,341 | 5/6/2019 | |
3.0.0-preview4.19216.2 | 23,261 | 4/18/2019 | |
3.0.0-preview3.19153.1 | 217,793 | 3/6/2019 | |
3.0.0-preview.19074.2 | 33,529 | 1/29/2019 | |
3.0.0-preview.18572.1 | 53,724 | 12/3/2018 | |
2.2.0 | 168,697,743 | 12/3/2018 | |
2.2.0-preview3-35497 | 244,432 | 10/17/2018 | |
2.2.0-preview2-35157 | 177,392 | 9/12/2018 | |
2.2.0-preview1-35029 | 103,626 | 8/22/2018 | |
2.1.23 | 38,029,486 | 10/13/2020 | |
2.1.2 | 34,804,799 | 8/21/2018 | |
2.1.1 | 50,761,865 | 6/18/2018 | |
2.1.0 | 74,290,270 | 5/29/2018 | |
2.1.0-rc1-final | 259,074 | 5/6/2018 | |
2.1.0-preview2-final | 251,552 | 4/10/2018 | |
2.1.0-preview1-final | 402,189 | 2/26/2018 | |
2.0.2 | 11,256,949 | 5/7/2018 | |
2.0.1 | 17,480,991 | 3/13/2018 | |
2.0.0 | 112,781,381 | 8/11/2017 | |
2.0.0-preview2-final | 136,030 | 6/28/2017 | |
2.0.0-preview1-final | 1,079,081 | 5/10/2017 | |
1.1.2 | 8,642,349 | 5/9/2017 | |
1.1.1 | 17,839,132 | 3/6/2017 | |
1.1.0 | 10,056,386 | 11/16/2016 | |
1.1.0-preview1-final | 70,801 | 10/24/2016 | |
1.0.2 | 4,424,777 | 3/6/2017 | |
1.0.1 | 628,051 | 12/12/2016 | |
1.0.0 | 288,474,465 | 6/27/2016 | |
1.0.0-rc2-final | 292,274 | 5/16/2016 | |
1.0.0-rc1-final | 515,543 | 11/18/2015 |