You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I expect CachingService.TryGetValue to return the value that I stored in the cache, but instead, it returns the Lazy that was used to generate the value. I would expect a call to GetValueFromLazy in this method to make sure the right object is returned. You will see this behavior if you use GetOrCreate to initially store the value, and then follow up with TryGetValue to read the value.
Also, because this re-uses T when calling CacheProvider.TryGetValue, it never finds the value. You would need to use CacheProvider.TryGetValue to be able to fetch the value.
Yeah this looks like a bug to me - thanks for submitting it. It should return the correctly typed object and unwrap the lazy using GetValueFromLazy in the same way the GetOrAdd does.
I expect CachingService.TryGetValue to return the value that I stored in the cache, but instead, it returns the Lazy that was used to generate the value. I would expect a call to GetValueFromLazy in this method to make sure the right object is returned. You will see this behavior if you use GetOrCreate to initially store the value, and then follow up with TryGetValue to read the value.
Also, because this re-uses T when calling CacheProvider.TryGetValue, it never finds the value. You would need to use CacheProvider.TryGetValue to be able to fetch the value.
Here is the TryGetValue method from https://github.com/alastairtree/LazyCache/blob/master/LazyCache/CachingService.cs.
` public virtual bool TryGetValue(string key, out T value)
{
ValidateKey(key);
`
The text was updated successfully, but these errors were encountered: