[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 TResult Get<TKey, TResult>(this ICacheManager cacheManager, TKey key, bool lazy, Func<AcquireContext<TKey>, TResult> acquire) {
// Wrap the call in a Lazy initializer to prevent multiple processes from
// executing the same lambda in parallel.
if (lazy) {
return cacheManager.Get<TKey, Lazy<TResult>>(key, k => new Lazy<TResult>(() => acquire(k))).Value;
public static TResult Get<TKey, TResult>(this ICacheManager cacheManager, TKey key, bool preventConcurrentCalls, Func<AcquireContext<TKey>, TResult> acquire) {
if (preventConcurrentCalls) {
lock(key) {
return cacheManager.Get(key, acquire);
}
}
else {
return cacheManager.Get(key, acquire);