MemoryCacheServiceCollectionExtensions.AddDistributedMemoryCache MemoryCacheServiceCollectionExtensions.AddDistributedMemoryCache MemoryCacheServiceCollectionExtensions.AddDistributedMemoryCache Method

Definition

Overloads

AddDistributedMemoryCache(IServiceCollection) AddDistributedMemoryCache(IServiceCollection) 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.

AddDistributedMemoryCache(IServiceCollection, Action<MemoryDistributedCacheOptions>) AddDistributedMemoryCache(IServiceCollection, Action<MemoryDistributedCacheOptions>) 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) AddDistributedMemoryCache(IServiceCollection) 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.

public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddDistributedMemoryCache (this Microsoft.Extensions.DependencyInjection.IServiceCollection services);
static member AddDistributedMemoryCache : Microsoft.Extensions.DependencyInjection.IServiceCollection -> Microsoft.Extensions.DependencyInjection.IServiceCollection
<Extension()>
Public Function AddDistributedMemoryCache (services As IServiceCollection) As IServiceCollection

Parameters

Returns

The IServiceCollection so that additional calls can be chained.

Remarks

AddDistributedMemoryCache(IServiceCollection) should only be used in single server scenarios as this cache stores items in memory and doesn't expand across multiple machines. For those scenarios it is recommended to use a proper distributed cache that can expand across multiple machines.

AddDistributedMemoryCache(IServiceCollection, Action<MemoryDistributedCacheOptions>) AddDistributedMemoryCache(IServiceCollection, Action<MemoryDistributedCacheOptions>) 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.

public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddDistributedMemoryCache (this Microsoft.Extensions.DependencyInjection.IServiceCollection services, Action<Microsoft.Extensions.Caching.Memory.MemoryDistributedCacheOptions> setupAction);
static member AddDistributedMemoryCache : Microsoft.Extensions.DependencyInjection.IServiceCollection * Action<Microsoft.Extensions.Caching.Memory.MemoryDistributedCacheOptions> -> Microsoft.Extensions.DependencyInjection.IServiceCollection
<Extension()>
Public Function AddDistributedMemoryCache (services As IServiceCollection, setupAction As Action(Of MemoryDistributedCacheOptions)) As IServiceCollection

Parameters

setupAction
Action<MemoryDistributedCacheOptions>

The Action<T> to configure the provided MemoryDistributedCacheOptions.

Returns

The IServiceCollection so that additional calls can be chained.

Remarks

AddDistributedMemoryCache(IServiceCollection) should only be used in single server scenarios as this cache stores items in memory and doesn't expand across multiple machines. For those scenarios it is recommended to use a proper distributed cache that can expand across multiple machines.

Applies to