This commit is contained in:
Stephan
2015-05-19 09:24:25 +02:00
parent 444a028e30
commit 16e06b6d4d
4 changed files with 6 additions and 80 deletions

View File

@@ -207,14 +207,10 @@ namespace Umbraco.Core.Cache
result = MemoryCache.Get(cacheKey) as Lazy<object>;
if (result == null || GetSafeLazyValue(result, true) == null) // get non-created as NonCreatedValue & exceptions as null
{
result = new Lazy<object>(getCacheItem);
var policy = GetPolicy(timeout, isSliding, removedCallback, dependentFiles);
lck.UpgradeToWriteLock();
result = new Lazy<object>(getCacheItem,
//NOTE: This is required to not cache any exceptions that throw when the callback is executed.
// we want to ensure the callback is re-executed and not cached in the case that it might no
// longer throw an exception if runtime circumstances have changed.
LazyThreadSafetyMode.PublicationOnly);
MemoryCache.Set(cacheKey, result, policy);
}
}
@@ -231,11 +227,7 @@ namespace Umbraco.Core.Cache
// NOTE - here also we must insert a Lazy<object> but we can evaluate it right now
// and make sure we don't store a null value.
var result = new Lazy<object>(getCacheItem,
//NOTE: This is required to not cache any exceptions that throw when the callback is executed.
// we want to ensure the callback is re-executed and not cached in the case that it might no
// longer throw an exception if runtime circumstances have changed.
LazyThreadSafetyMode.PublicationOnly);
var result = new Lazy<object>(getCacheItem);
var value = result.Value; // force evaluation now
if (value == null) return; // do not store null values (backward compat)