mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
[Fixes #5835] Restoring cache invalidation propagation
This commit is contained in:
@@ -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);
|
||||||
|
Reference in New Issue
Block a user