Microsoft.Extensions.Caching.Memory 10.0.3
Prefix ReservedSee the version list below for details.
dotnet add package Microsoft.Extensions.Caching.Memory --version 10.0.3NuGet\Install-Package Microsoft.Extensions.Caching.Memory -Version 10.0.3<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="10.0.3" /><PackageVersion Include="Microsoft.Extensions.Caching.Memory" Version="10.0.3" />Directory.Packages.props
<PackageReference Include="Microsoft.Extensions.Caching.Memory" />Project file
paket add Microsoft.Extensions.Caching.Memory --version 10.0.3#r "nuget: Microsoft.Extensions.Caching.Memory, 10.0.3"#:package Microsoft.Extensions.Caching.Memory@10.0.3#addin nuget:?package=Microsoft.Extensions.Caching.Memory&version=10.0.3Install as a Cake Addin
#tool nuget:?package=Microsoft.Extensions.Caching.Memory&version=10.0.3Install as a Cake Tool
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 entriesstring 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.MemoryCacheMicrosoft.Extensions.Caching.Memory.MemoryCacheOptionsMicrosoft.Extensions.Caching.Distributed.MemoryDistributedCacheMicrosoft.Extensions.Caching.Memory.MemoryDistributedCacheOptions
Additional Documentation
Related Packages
Microsoft.Extensions.Caching.Abstractions
Feedback & Contributing
Microsoft.Extensions.Caching.Memory is released as open source under theMIT license. Bug reports and contributions are welcome atthe GitHub repository.
| Product | VersionsCompatible 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. 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. |
| .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(>= 10.0.3)
- Microsoft.Extensions.DependencyInjection.Abstractions(>= 10.0.3)
- Microsoft.Extensions.Logging.Abstractions(>= 10.0.3)
- Microsoft.Extensions.Options(>= 10.0.3)
- Microsoft.Extensions.Primitives(>= 10.0.3)
- System.ValueTuple(>= 4.6.1)
.NETStandard 2.0
- Microsoft.Extensions.Caching.Abstractions(>= 10.0.3)
- Microsoft.Extensions.DependencyInjection.Abstractions(>= 10.0.3)
- Microsoft.Extensions.Logging.Abstractions(>= 10.0.3)
- Microsoft.Extensions.Options(>= 10.0.3)
- Microsoft.Extensions.Primitives(>= 10.0.3)
net10.0
- Microsoft.Extensions.Caching.Abstractions(>= 10.0.3)
- Microsoft.Extensions.DependencyInjection.Abstractions(>= 10.0.3)
- Microsoft.Extensions.Logging.Abstractions(>= 10.0.3)
- Microsoft.Extensions.Options(>= 10.0.3)
- Microsoft.Extensions.Primitives(>= 10.0.3)
net8.0
- Microsoft.Extensions.Caching.Abstractions(>= 10.0.3)
- Microsoft.Extensions.DependencyInjection.Abstractions(>= 10.0.3)
- Microsoft.Extensions.Logging.Abstractions(>= 10.0.3)
- Microsoft.Extensions.Options(>= 10.0.3)
- Microsoft.Extensions.Primitives(>= 10.0.3)
net9.0
- Microsoft.Extensions.Caching.Abstractions(>= 10.0.3)
- Microsoft.Extensions.DependencyInjection.Abstractions(>= 10.0.3)
- Microsoft.Extensions.Logging.Abstractions(>= 10.0.3)
- Microsoft.Extensions.Options(>= 10.0.3)
- Microsoft.Extensions.Primitives(>= 10.0.3)
NuGet packages (3.4K)
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.DbContextMicrosoft.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 (328)
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. | |
| duplicati/duplicati Store securely encrypted backups in the cloud! | |
| 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. | |
| 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+. | |
| Flow-Launcher/Flow.Launcher :mag: Quick file search & app launcher for Windows with community-made plugins | |
| aspnetboilerplate/aspnetboilerplate ASP.NET Boilerplate - Web Application Framework | |
| JeffreySu/WeiXinMPSDK 微信全平台 .NET SDK, Senparc.Weixin for C#,支持 .NET Framework 及 .NET Core、.NET 10.0。已支持微信公众号、小程序、小游戏、微信支付、企业微信/企业号、开放平台、JSSDK、微信周边等全平台。 WeChat SDK for C#. | |
| ThreeMammals/Ocelot .NET API Gateway | |
| MassTransit/MassTransit Distributed Application Framework for .NET | |
| elsa-workflows/elsa-core The Workflow Engine for .NET | |
| LykosAI/StabilityMatrix Multi-Platform Package Manager for Stable Diffusion | |
| graphql-dotnet/graphql-dotnet GraphQL for .NET | |
| DotNetNext/SqlSugar .Net aot ORM SqlServer ORM Mongodb ORM MySql 瀚高 Postgresql ORM DB2 Hana 高斯 Duckdb C# VB.NET Sqlite ORM Oracle ORM Mysql Orm 虚谷数据库 达梦 ORM 人大金仓 ORM 神通ORM C# ORM , C# ORM .NET ORM NET9 ORM .NET8 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. | |
| 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 | |
| dotnet/aspire Aspire is the tool for code-first, extensible, observable dev and deploy. | |
| 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. |
| Version | Downloads | Last Updated |
|---|---|---|
| 11.0.0-preview.1.26104.118 | 1,517 | 2/10/2026 |
| 10.0.3 | 938,591 | 2/10/2026 |
| 10.0.2 | 4,514,593 | 1/13/2026 |
| 10.0.1 | 5,406,385 | 12/9/2025 |
| 10.0.0 | 9,905,854 | 11/11/2025 |
| 10.0.0-rc.2.25502.107 | 344,235 | 10/14/2025 |
| 10.0.0-rc.1.25451.107 | 143,353 | 9/9/2025 |
| 10.0.0-preview.7.25380.108 | 42,965 | 8/12/2025 |
| 10.0.0-preview.6.25358.103 | 18,753 | 7/15/2025 |
| 10.0.0-preview.5.25277.114 | 62,509 | 6/6/2025 |
| 10.0.0-preview.4.25258.110 | 40,538 | 5/12/2025 |
| 9.0.13 | 158,932 | 2/10/2026 |
| 9.0.12 | 1,026,710 | 1/13/2026 |
| 9.0.11 | 6,151,124 | 11/11/2025 |
| 9.0.10 | 10,635,824 | 10/14/2025 |
| 9.0.9 | 13,292,271 | 9/9/2025 |
| 9.0.8 | 12,419,779 | 8/4/2025 |
| 9.0.7 | 9,996,669 | 7/8/2025 |
| 9.0.6 | 11,652,685 | 6/10/2025 |
| 9.0.5 | 14,058,225 | 5/13/2025 |
- Last updated2/10/2026
- Project website
- Source repository
- MIT license
- Download package (191.89 KB)
- Open in NuGet Package Explorer
Open in NuGet Trends
- Report package
© Microsoft Corporation. All rights reserved.