Microsoft.Extensions.Caching.Memory 10.0.3

Prefix Reserved
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package Microsoft.Extensions.Caching.Memory --version 10.0.3
NuGet\Install-Package Microsoft.Extensions.Caching.Memory -Version 10.0.3
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version ofInstall-Package.
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="10.0.3" />
For projects that supportPackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Microsoft.Extensions.Caching.Memory" Version="10.0.3" />
Directory.Packages.props
<PackageReference Include="Microsoft.Extensions.Caching.Memory" />
Project file
For projects that supportCentral Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Microsoft.Extensions.Caching.Memory --version 10.0.3
The NuGet Team does not provide support for this client. Please contact itsmaintainers for support.
#r "nuget: Microsoft.Extensions.Caching.Memory, 10.0.3"
#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 Microsoft.Extensions.Caching.Memory@10.0.3
#: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=Microsoft.Extensions.Caching.Memory&version=10.0.3
Install as a Cake Addin
#tool nuget:?package=Microsoft.Extensions.Caching.Memory&version=10.0.3
Install as a Cake Tool
The NuGet Team does not provide support for this client. Please contact itsmaintainers for support.

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.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 theMIT license. Bug reports and contributions are welcome atthe GitHub repository.

ProductCompatible and additional computed target framework versions.
.NETnet5.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 Corenetcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. 
.NET Standardnetstandard2.0 is compatible. netstandard2.1 was computed. 
.NET Frameworknet461 was computed. net462 is compatible. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. 
MonoAndroidmonoandroid was computed. 
MonoMacmonomac was computed. 
MonoTouchmonotouch was computed. 
Tizentizen40 was computed. tizen60 was computed. 
Xamarin.iOSxamarinios was computed. 
Xamarin.Macxamarinmac was computed. 
Xamarin.TVOSxamarintvos was computed. 
Xamarin.WatchOSxamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more aboutTarget Frameworks and.NET Standard.

NuGet packages (3.4K)

Showing the top 5 NuGet packages that depend on Microsoft.Extensions.Caching.Memory:

PackageDownloads
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:

RepositoryStars
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.
VersionDownloads Last Updated
11.0.0-preview.1.26104.118 1,5172/10/2026
10.0.3 938,5912/10/2026
10.0.2 4,514,5931/13/2026
10.0.1 5,406,38512/9/2025
10.0.0 9,905,85411/11/2025
10.0.0-rc.2.25502.107 344,23510/14/2025
10.0.0-rc.1.25451.107 143,3539/9/2025
10.0.0-preview.7.25380.108 42,9658/12/2025
10.0.0-preview.6.25358.103 18,7537/15/2025
10.0.0-preview.5.25277.114 62,5096/6/2025
10.0.0-preview.4.25258.110 40,5385/12/2025
9.0.13 158,9322/10/2026
9.0.12 1,026,7101/13/2026
9.0.11 6,151,12411/11/2025
9.0.10 10,635,82410/14/2025
9.0.9 13,292,2719/9/2025
9.0.8 12,419,7798/4/2025
9.0.7 9,996,6697/8/2025
9.0.6 11,652,6856/10/2025
9.0.5 14,058,2255/13/2025
Loading failed
Downloads
Total3.0B
Current version938.6K
Per day average10.4M
About
Owners

© Microsoft Corporation. All rights reserved.

Share this package on FacebookShare this package on XUse the Atom feed to subscribe to new versions of Microsoft.Extensions.Caching.Memory