PostSharpAPI ReferencePost­Sharp.​Patterns.​Caching.​BackendsMemory­Cache­Backend
Open sandboxFocus

MemoryCacheBackend Class

A CachingBackend based on Microsoft.Extensions.Caching.Memory.IMemoryCache (Microsoft.Extensions.Caching.Memory.IMemoryCache). This cache is recommended for ASP.NET Core use (as opposed to System.Runtime.Caching.MemoryCache).

Inheritance
MemoryCacheBackend
Implements
IDisposable
Namespace: PostSharp.Patterns.Caching.Backends
Assembly: PostSharp.Patterns.Caching.Backends.IMemoryCache.dll
Syntax
public class MemoryCacheBackend : CachingBackend
Remarks

This backend converts PostSharp configuration properties into ICacheEntry instances as follows:

Constructors

Name Description
MemoryCacheBackend()

Initializes a new MemoryCacheBackend based on a new instance of the MemoryCache class.

MemoryCacheBackend(IMemoryCache)

Initializes a new MemoryCacheBackend based on the given Microsoft.Extensions.Caching.Memory.IMemoryCache.

MemoryCacheBackend(IMemoryCache, Func<CacheItem, Int64>)

Initializes a new MemoryCacheBackend based on the given Microsoft.Extensions.Caching.Memory.IMemoryCache. The backend creates cache entries with size calculated by the given function.

Methods

Name Description
ClearCore()

Clears the cache. This protected method is part of the implementation API and is meant to be overridden in user code, not invoked.

ContainsDependencyCore(String)

Determines whether the cache contains a given dependency. This protected method is part of the implementation API and is meant to be overridden in user code, not invoked. Arguments are already validated by the consumer API.

ContainsItemCore(String)

Determines whether the cache contains an item of a given key. This protected method is part of the implementation API and is meant to be overridden in user code, not invoked. Arguments are already validated by the consumer API.

CreateFeatures()

Creates a CachingBackendFeatures object, which describes set of features implemented by the back-end. This method is invoked the first time the SupportedFeatures property is evaluated. The result is then cached.

DisposeAsyncCore(CancellationToken)

Asynchronously disposes the current CachingBackend. This protected method is part of the implementation API and is meant to be overridden in user code, not invoked.

DisposeCore(Boolean)

Synchronously disposes the current CachingBackend. This protected method is part of the implementation API and is meant to be overridden in user code, not invoked.

GetItemCore(String, Boolean)

Gets a cache item given its key. This protected method is part of the implementation API and is meant to be overridden in user code, not invoked. Arguments are already validated by the consumer API.

InvalidateDependencyCore(String)

Removes from the cache all items that have a specific dependency. This protected method is part of the implementation API and is meant to be overridden in user code, not invoked. Arguments are already validated by the consumer API.

RemoveItemCore(String)

Removes a cache item from the cache given its key. This protected method is part of the implementation API and is meant to be overridden in user code, not invoked. Arguments are already validated by the consumer API.

SetItemCore(String, CacheItem)

Sets a cache item. This protected method is part of the implementation API and is meant to be overridden in user code, not invoked. Arguments are already validated by the consumer API.