CacheExtensions.TryGetValue<TItem>(IMemoryCache, Object, TItem) Method

Definition

Tries to get the value associated with the given key.

C#
public static bool TryGetValue<TItem>(this Microsoft.Extensions.Caching.Memory.IMemoryCache cache, object key, out TItem? value);

Type Parameters

TItem

The type of the object to get.

Parameters

cache
IMemoryCache

The IMemoryCache instance this method extends.

key
Object

The key of the value to get.

value
TItem

The value associated with the given key.

Returns

true if the key was found; false otherwise.

Applies to

Product Versions
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Standard 2.0 (package-provided)