dotnetcore / EasyCaching

:boom: EasyCaching is an open source caching library that contains basic usages and some advanced usages of caching which can help us to handle caching more easier!
MIT License
1.92k stars 324 forks source link

Clear lock on exception in disk cache GetAsync, ignore _Lock keys on Init() #529

Closed dplarina closed 4 months ago

dplarina commented 4 months ago

Fixes #523

If the implementation's dataRetriever() throws an exception, the relevant cache key stays locked and will never recover. This removes the lock if there is an exception.

Also when the disk cache provider is initialized, added ignoring existing _Lock keys for situations where the app crashed or was restarted while the Lock was saved to the keys.dat.

Memoyu commented 4 months ago

image

Hello, there are some problems when running unit tests. Please adjust them. Thank you for your PR.

dplarina commented 4 months ago

Sorry. I can't even find the relevant test to begin to know how to troubleshoot that.

Also the failure appears be happening in code unrelated to the code change. I assume this test is ensuring that multiple threads can access the cached value (cache hits), while the code change is related to cache misses.

catcherwong commented 4 months ago

All CI check have passed. @Memoyu