MemoryCacheServiceCollectionExtensions Class

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

Namespace
Microsoft.Extensions.DependencyInjection
Assemblies
  • Microsoft.Extensions.Caching.Memory

Syntax

public class MemoryCacheServiceCollectionExtensions
class Microsoft.Extensions.DependencyInjection.MemoryCacheServiceCollectionExtensions

Methods

AddDistributedMemoryCache(Microsoft.Extensions.DependencyInjection.IServiceCollection)

Adds a default implementation of Microsoft.Extensions.Caching.Distributed.IDistributedCache that stores items in memory to the Microsoft.Extensions.DependencyInjection.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.

Arguments:services (Microsoft.Extensions.DependencyInjection.IServiceCollection) – The Microsoft.Extensions.DependencyInjection.IServiceCollection to add services to.
Return type:Microsoft.Extensions.DependencyInjection.IServiceCollection
Returns:The Microsoft.Extensions.DependencyInjection.IServiceCollection so that additional calls can be chained.
public static IServiceCollection AddDistributedMemoryCache(this IServiceCollection services)
AddMemoryCache(Microsoft.Extensions.DependencyInjection.IServiceCollection)

Adds a non distributed in memory implementation of Microsoft.Extensions.Caching.Memory.IMemoryCache to the Microsoft.Extensions.DependencyInjection.IServiceCollection.

Arguments:services (Microsoft.Extensions.DependencyInjection.IServiceCollection) – The Microsoft.Extensions.DependencyInjection.IServiceCollection to add services to.
Return type:Microsoft.Extensions.DependencyInjection.IServiceCollection
Returns:The Microsoft.Extensions.DependencyInjection.IServiceCollection so that additional calls can be chained.
public static IServiceCollection AddMemoryCache(this IServiceCollection services)
AddMemoryCache(Microsoft.Extensions.DependencyInjection.IServiceCollection, System.Action<Microsoft.Extensions.Caching.Memory.MemoryCacheOptions>)

Adds a non distributed in memory implementation of Microsoft.Extensions.Caching.Memory.IMemoryCache to the Microsoft.Extensions.DependencyInjection.IServiceCollection.

Arguments:
Return type:

Microsoft.Extensions.DependencyInjection.IServiceCollection

Returns:

The Microsoft.Extensions.DependencyInjection.IServiceCollection so that additional calls can be chained.

public static IServiceCollection AddMemoryCache(this IServiceCollection services, Action<MemoryCacheOptions> setupAction)