Skip to content

CachingService.TryGetValue returning wrong value #176

Open
@Coder3333

Description

@Coder3333

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

        return CacheProvider.TryGetValue(key, out value);
    }

`

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions