Table of Contents

Class MemoryCacheExtension

Namespace
Arc4u.Configuration.Memory
Assembly
Arc4u.Caching.dll

Extension methods to register the options of a memory cache.

public static class MemoryCacheExtension
Inheritance
MemoryCacheExtension
Inherited Members

Methods

AddMemoryCache(IServiceCollection, string, IConfiguration, string)

Registers the options of the memory cache with the given name from a configuration section. Nothing is registered when the section does not exist.

public static IServiceCollection AddMemoryCache(this IServiceCollection services, string name, IConfiguration configuration, string sectionName)

Parameters

services IServiceCollection

The service collection.

name string

The name of the cache, as used in Name.

configuration IConfiguration

The application configuration.

sectionName string

The path of the section that holds the MemoryCacheOption values.

Returns

IServiceCollection

The same IServiceCollection, for chaining.

Exceptions

ArgumentException

name is null or empty and the section exists.

AddMemoryCache(IServiceCollection, string, Action<MemoryCacheOption>)

Registers the options of the memory cache with the given name.

public static IServiceCollection AddMemoryCache(this IServiceCollection services, string name, Action<MemoryCacheOption> options)

Parameters

services IServiceCollection

The service collection.

name string

The name of the cache, as used in Name.

options Action<MemoryCacheOption>

The action that configures the options.

Returns

IServiceCollection

The same IServiceCollection, for chaining.

Examples

builder.Services.AddMemoryCache("Volatile", o => o.SizeLimitInMB = 50);

Exceptions

ArgumentException

name is null or empty.