diff --git a/src/Umbraco.Core/Cache/ObjectCacheAppCache.cs b/src/Umbraco.Core/Cache/ObjectCacheAppCache.cs
index 1bdfec2450..4b9d237ea4 100644
--- a/src/Umbraco.Core/Cache/ObjectCacheAppCache.cs
+++ b/src/Umbraco.Core/Cache/ObjectCacheAppCache.cs
@@ -1,6 +1,5 @@
using System.Text.RegularExpressions;
using Microsoft.Extensions.Caching.Memory;
-using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using Microsoft.Extensions.Options;
@@ -9,19 +8,17 @@ using Umbraco.Extensions;
namespace Umbraco.Cms.Core.Cache;
///
-/// Implements on top of a .
+/// Implements on top of a .
///
public class ObjectCacheAppCache : IAppPolicyCache, IDisposable
{
- private readonly IOptions _options;
- private readonly IHostEnvironment? _hostEnvironment;
private readonly ISet _keys = new HashSet();
- private static readonly TimeSpan _readLockTimeout = TimeSpan.FromSeconds(5);
- private static readonly TimeSpan _writeLockTimeout = TimeSpan.FromSeconds(5);
-
private readonly ReaderWriterLockSlim _locker = new(LockRecursionPolicy.SupportsRecursion);
private bool _disposedValue;
+ private static readonly TimeSpan _readLockTimeout = TimeSpan.FromSeconds(5);
+ private static readonly TimeSpan _writeLockTimeout = TimeSpan.FromSeconds(5);
+
///
/// Gets the internal memory cache, for tests only!
///
@@ -34,7 +31,7 @@ public class ObjectCacheAppCache : IAppPolicyCache, IDisposable
/// Initializes a new instance of the .
///
public ObjectCacheAppCache()
- : this(Options.Create(new MemoryCacheOptions()), NullLoggerFactory.Instance, null)
+ : this(new MemoryCacheOptions(), NullLoggerFactory.Instance)
{ }
///
@@ -42,14 +39,8 @@ public class ObjectCacheAppCache : IAppPolicyCache, IDisposable
///
/// The options.
/// The logger factory.
- /// The host environment.
- public ObjectCacheAppCache(IOptions options, ILoggerFactory loggerFactory, IHostEnvironment? hostEnvironment)
- {
- _options = options;
- _hostEnvironment = hostEnvironment;
-
- MemoryCache = new MemoryCache(_options, loggerFactory);
- }
+ internal ObjectCacheAppCache(IOptions options, ILoggerFactory loggerFactory)
+ => MemoryCache = new MemoryCache(options, loggerFactory);
///
public object? Get(string key)
@@ -59,8 +50,9 @@ public class ObjectCacheAppCache : IAppPolicyCache, IDisposable
{
if (_locker.TryEnterReadLock(_readLockTimeout) is false)
{
- throw new TimeoutException("Timeout exceeded to the memory cache when getting item");
+ throw new TimeoutException("Timeout exceeded to the memory cache when getting item by key.");
}
+
result = MemoryCache.Get(key) as Lazy