LazyCache
LazyCache copied to clipboard
TryGetValue() fails (wrong value type) if the value was added Async.
I suggest the following code instead:
public static bool ExTryGetValue<T>(this IAppCache service, string key, out T? value) where T : class
{
var item = service.Get<T>(key);
if (item is null)
{
value = null;
return false;
}
value = item;
return true;
}