[Fixes #5835] Restoring cache invalidation propagation

This commit is contained in:
Sebastien Ros
2015-09-23 16:14:19 -07:00
parent f2fb1d520d
commit b7a0b007e4

View File

@@ -7,11 +7,11 @@ namespace Orchard.Caching {
} }
public static class CacheManagerExtensions { public static class CacheManagerExtensions {
public static TResult Get<TKey, TResult>(this ICacheManager cacheManager, TKey key, bool lazy, Func<AcquireContext<TKey>, TResult> acquire) { public static TResult Get<TKey, TResult>(this ICacheManager cacheManager, TKey key, bool preventConcurrentCalls, Func<AcquireContext<TKey>, TResult> acquire) {
// Wrap the call in a Lazy initializer to prevent multiple processes from if (preventConcurrentCalls) {
// executing the same lambda in parallel. lock(key) {
if (lazy) { return cacheManager.Get(key, acquire);
return cacheManager.Get<TKey, Lazy<TResult>>(key, k => new Lazy<TResult>(() => acquire(k))).Value; }
} }
else { else {
return cacheManager.Get(key, acquire); return cacheManager.Get(key, acquire);