-
Notifications
You must be signed in to change notification settings - Fork 333
Closed
Labels
Description
Steps to Reproduce
- Set LockMs setting to N seconds (100000 for example)
- Call GetAsync DefaultInMemoryCachingProvider with data retriever that throws an exception
- Call GetAsync with same key in parallel.
- GetAsync call on step 3 will be await for N seconds cause DefaultInMemoryCachingProvider will not remove _Lock flag on exception.
Related code
EasyCaching/src/EasyCaching.InMemory/DefaultInMemoryCachingProvider.cs
Lines 120 to 135 in 152cbe7
var res = dataRetriever(); | |
if (res != null || _options.CacheNulls) | |
{ | |
Set(cacheKey, res, expiration); | |
//remove mutex key | |
_cache.Remove($"{cacheKey}_Lock"); | |
return new CacheValue<T>(res, true); | |
} | |
else | |
{ | |
//remove mutex key | |
_cache.Remove($"{cacheKey}_Lock"); | |
return CacheValue<T>.NoValue; | |
} |
Solution:
Remove _Lock key also when dataRetriever throw an exception.