LazyCache icon indicating copy to clipboard operation
LazyCache copied to clipboard

TryGetValue() fails (wrong value type) if the value was added Async.

Open DavidThielen opened this issue 1 year ago • 0 comments

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;
       }

DavidThielen avatar Mar 22 '24 15:03 DavidThielen