SiteDomainHelper cleanup (#10166)

* Fixes SiteDomainHelper = no more static weirdness and renames it.

* fix build
This commit is contained in:
Shannon Deminick
2021-04-22 20:25:25 +10:00
committed by GitHub
parent 181c8cbc34
commit c991e83088
27 changed files with 314 additions and 326 deletions

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Caching;
@@ -107,19 +107,34 @@ namespace Umbraco.Cms.Core.Cache
Lazy<object> result;
using (var lck = new UpgradeableReadLock(_locker))
try
{
_locker.EnterUpgradeableReadLock();
result = MemoryCache.Get(key) as Lazy<object>;
if (result == null || SafeLazy.GetSafeLazyValue(result, true) == null) // get non-created as NonCreatedValue & exceptions as null
{
result = SafeLazy.GetSafeLazy(factory);
var policy = GetPolicy(timeout, isSliding, dependentFiles);
lck.UpgradeToWriteLock();
//NOTE: This does an add or update
MemoryCache.Set(key, result, policy);
try
{
_locker.EnterWriteLock();
//NOTE: This does an add or update
MemoryCache.Set(key, result, policy);
}
finally
{
if (_locker.IsWriteLockHeld)
_locker.ExitWriteLock();
}
}
}
finally
{
if (_locker.IsUpgradeableReadLockHeld)
_locker.ExitUpgradeableReadLock();
}
//return result.Value;