Skip to content

TryGet

TryGet retrieves a value from the cache by key. A result object is always returned; no exception is raised if the key is not found.


The key of the entry to retrieve.

Accepts string literals, expressions, or references to string values.

Returns an object with the following properties:

PropertyTypeDescription
WasFoundBooleantrue if the key exists in the cache, false otherwise.
ValueMatches the Value type set on the Cache serviceThe cached value when WasFound is true. Returns null when WasFound is false.

Example output when the key exists:

{
"WasFound": True,
"Value": "MyValue"
}

Example output when the key does not exist:

{
"WasFound": False,
"Value": <NULL>
}