IMemoryCache Interface

Represents a local in-memory cache whose values are not serialized.

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

Syntax

public interface IMemoryCache : IDisposable
interface Microsoft.Extensions.Caching.Memory.IMemoryCache

Methods

CreateEntry(System.Object)

Create or overwrite an entry in the cache.

Arguments:key (System.Object) – An object identifying the entry.
Return type:Microsoft.Extensions.Caching.Memory.ICacheEntry
Returns:The newly created Microsoft.Extensions.Caching.Memory.ICacheEntry instance.
ICacheEntry CreateEntry(object key)
Remove(System.Object)

Removes the object associated with the given key.

Arguments:key (System.Object) – An object identifying the entry.
void Remove(object key)
TryGetValue(System.Object, out System.Object)

Gets the item associated with this key if present.

Arguments:
  • key (System.Object) – An object identifying the requested entry.
  • value (System.Object) – The located value or null.
Return type:

System.Boolean

Returns:

True if the key was found.

bool TryGetValue(object key, out object value)