mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-04-05 21:01:35 +08:00
[Fixes #5835] Restoring cache invalidation propagation
This commit is contained in:
parent
f2fb1d520d
commit
b7a0b007e4
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user