Skip to content

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

@DavidThielen

Description

@DavidThielen

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions