CacheService.GetAsync
Reference
Task<T> GetAsync<T>(string key)
Use GetAsync to retrieve a value from the cache by logical key. If the key is not found the method returns the default value of T (for example null for reference types, 0 for numeric types).
Parameters
key: Logical cache key. Do not include any environment-specific prefix. Keys are case-sensitive.
Returns
Task<T>: The cached value or default(T) when the key is not present.
Error Handling & Caveats
- If
keyisnullor empty, an ArgumentException is thrown. - If the cache backend is unavailable, the method may throw a backend-specific exception (for example RedisConnectionException). Callers should handle transient errors and implement retry/backoff where appropriate.
- The cache returns
default(T)when a key is absent or expired; callers should treatdefault(T)as "not present" rather than a guaranteed persisted zero-like value. - Values are deserialized into
T; deserialization errors will raise exceptions (e.g.JsonException).