MemoryCacheServiceCollectionExtensions Class

Definition

Important

Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

Extension methods for setting up memory cache related services in an IServiceCollection.

C#
public static class MemoryCacheServiceCollectionExtensions
Inheritance
MemoryCacheServiceCollectionExtensions

Methods

AddDistributedMemoryCache(IServiceCollection, Action<MemoryDistributedCacheOptions>)

Adds a default implementation of IDistributedCache that stores items in memory to the IServiceCollection. Frameworks that require a distributed cache to work can safely add this dependency as part of their dependency list to ensure that there is at least one implementation available.

AddDistributedMemoryCache(IServiceCollection)

Adds a default implementation of IDistributedCache that stores items in memory to the IServiceCollection. Frameworks that require a distributed cache to work can safely add this dependency as part of their dependency list to ensure that there is at least one implementation available.

AddMemoryCache(IServiceCollection, Action<MemoryCacheOptions>)

Adds a non distributed in-memory implementation of IMemoryCache to the IServiceCollection.

AddMemoryCache(IServiceCollection)

Adds a non distributed in-memory implementation of IMemoryCache to the IServiceCollection.

Applies to

Product Versions
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Standard 2.0 (package-provided)