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.
Properties
Key
The key of the entry to retrieve.
Accepts string literals, expressions, or references to string values.
Output
Returns an object with the following properties:
WasFound
Boolean
true if the key exists in the cache, false otherwise.
Value
Matches the Value type set on the Cache service
The 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:
Note
Check WasFound before using Value. When WasFound is False, Value is null regardless of the Value type set on the service.
Warning
Calling TryGet while the Cache service is not running will throw an exception.
Last updated