Skip to content

TryGetValue Method ​

Definition ​

  • Namespace: JASE.Caching
  • Assembly: JASE.Caching.dll

bool TryGetValue(TKey key, out TValue value) ​

csharp
bool TryGetValue(TKey key, out TValue value)

Attempts to get the value associated with the specified key.

Parameters ​

NameDescription
keyThe cache key.
valueWhen this method returns true, contains the value associated with the specified key. When this method returns false, contains the default value for TValue.

Returns ​

true if the key was found and the entry is not expired; otherwise false.

Remarks ​

A successful read refreshes sliding expiration. If the entry is found but expired, it is removed and treated as a miss.