alastairtree / LazyCache

An easy to use thread safe in-memory caching service with a simple developer friendly API for c#
https://nuget.org/packages/LazyCache
MIT License
1.72k stars 159 forks source link

GetOrAddAsync doesn't call GetOrCreateAsync in the provider #112

Open replaysMike opened 4 years ago

replaysMike commented 4 years ago

Trying to write a Redis provider for the current version of LazyCache. Ended up hitting a wall with the current implementation.

The bug When calling _cache.GetOrAddAsync() the caching service calls the GetOrCreate on the underlying provider instead of GetOrCreateAsync. This prevents the task from being unwrapped correctly and the resulting object is wrong.

CachingService.cs:172 and CachingService.cs:192.

Couldn't find an easy way around it because of the way the CacheFactory is used, and passes the type as an object