diff --git a/Directory.Packages.props b/Directory.Packages.props index dc3d710e2f..0f029e9754 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -19,6 +19,7 @@ + @@ -32,7 +33,6 @@ - diff --git a/src/Umbraco.Core/Cache/AppCacheExtensions.cs b/src/Umbraco.Core/Cache/AppCacheExtensions.cs index aa1c7e3333..55079ba018 100644 --- a/src/Umbraco.Core/Cache/AppCacheExtensions.cs +++ b/src/Umbraco.Core/Cache/AppCacheExtensions.cs @@ -65,15 +65,14 @@ public static class AppCacheExtensions string cacheKey, Func> getCacheItemAsync, TimeSpan? timeout, - bool isSliding = false, - string[]? dependentFiles = null) + bool isSliding = false) { var result = provider.Get(cacheKey); if (result == null) { result = await getCacheItemAsync(); - provider.Insert(cacheKey, () => result, timeout, isSliding, dependentFiles); + provider.Insert(cacheKey, () => result, timeout, isSliding); } return result == null ? default : result.TryConvertTo().Result; @@ -84,10 +83,9 @@ public static class AppCacheExtensions string cacheKey, Func> getCacheItemAsync, TimeSpan? timeout = null, - bool isSliding = false, - string[]? dependentFiles = null) + bool isSliding = false) { T value = await getCacheItemAsync(); - provider.Insert(cacheKey, () => value, timeout, isSliding, dependentFiles); + provider.Insert(cacheKey, () => value, timeout, isSliding); } } diff --git a/src/Umbraco.Core/Cache/ObjectCacheAppCache.cs b/src/Umbraco.Core/Cache/ObjectCacheAppCache.cs index e53727b152..54ebde6f57 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.FileProviders; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; @@ -106,7 +105,7 @@ public class ObjectCacheAppCache : IAppPolicyCache, IDisposable } /// - public object? Get(string key, Func factory, TimeSpan? timeout, bool isSliding = false, string[]? dependentFiles = null) + public object? Get(string key, Func factory, TimeSpan? timeout, bool isSliding = false) { // see notes in HttpRuntimeAppCache Lazy? result; @@ -121,7 +120,7 @@ public class ObjectCacheAppCache : IAppPolicyCache, IDisposable if (result == null || SafeLazy.GetSafeLazyValue(result, true) == null) { result = SafeLazy.GetSafeLazy(factory); - MemoryCacheEntryOptions options = GetOptions(timeout, isSliding, dependentFiles); + MemoryCacheEntryOptions options = GetOptions(timeout, isSliding); try { @@ -159,7 +158,7 @@ public class ObjectCacheAppCache : IAppPolicyCache, IDisposable } /// - public void Insert(string key, Func factory, TimeSpan? timeout = null, bool isSliding = false, string[]? dependentFiles = null) + public void Insert(string key, Func factory, TimeSpan? timeout = null, bool isSliding = false) { // NOTE - here also we must insert a Lazy but we can evaluate it right now // and make sure we don't store a null value. @@ -170,7 +169,7 @@ public class ObjectCacheAppCache : IAppPolicyCache, IDisposable return; // do not store null values (backward compat) } - MemoryCacheEntryOptions options = GetOptions(timeout, isSliding, dependentFiles); + MemoryCacheEntryOptions options = GetOptions(timeout, isSliding); // NOTE: This does an add or update MemoryCache.Set(key, result, options); @@ -323,7 +322,7 @@ public class ObjectCacheAppCache : IAppPolicyCache, IDisposable } } - private MemoryCacheEntryOptions GetOptions(TimeSpan? timeout = null, bool isSliding = false, string[]? dependentFiles = null) + private MemoryCacheEntryOptions GetOptions(TimeSpan? timeout = null, bool isSliding = false) { var options = new MemoryCacheEntryOptions(); @@ -337,19 +336,6 @@ public class ObjectCacheAppCache : IAppPolicyCache, IDisposable options.AbsoluteExpirationRelativeToNow = timeout; } - // Configure file based expiration - if (dependentFiles?.Length > 0 && _hostEnvironment?.ContentRootFileProvider is IFileProvider fileProvider) - { - foreach (var dependentFile in dependentFiles) - { - var relativePath = Path.IsPathFullyQualified(dependentFile) - ? Path.GetRelativePath(_hostEnvironment.ContentRootPath, dependentFile) - : dependentFile; - - options.ExpirationTokens.Add(fileProvider.Watch(relativePath)); - } - } - // Ensure key is removed from set when evicted from cache return options.RegisterPostEvictionCallback((key, _, _, _) => _keys.Remove((string)key)); } diff --git a/src/Umbraco.Core/Umbraco.Core.csproj b/src/Umbraco.Core/Umbraco.Core.csproj index 4c80fc55d7..e2e869e8ba 100644 --- a/src/Umbraco.Core/Umbraco.Core.csproj +++ b/src/Umbraco.Core/Umbraco.Core.csproj @@ -7,6 +7,7 @@ + @@ -17,19 +18,6 @@ - - - - - - - - - - - - - diff --git a/src/Umbraco.Infrastructure/BackgroundJobs/Jobs/OpenIddictCleanupJob.cs b/src/Umbraco.Infrastructure/BackgroundJobs/Jobs/OpenIddictCleanupJob.cs index 7cb0575177..6c93d4a649 100644 --- a/src/Umbraco.Infrastructure/BackgroundJobs/Jobs/OpenIddictCleanupJob.cs +++ b/src/Umbraco.Infrastructure/BackgroundJobs/Jobs/OpenIddictCleanupJob.cs @@ -38,7 +38,7 @@ public class OpenIddictCleanupJob : IRecurringBackgroundJob try { IOpenIddictTokenManager tokenManager = scope.ServiceProvider.GetService() - ?? throw new ConfigurationErrorsException($"Could not retrieve an {nameof(IOpenIddictTokenManager)} service from the current scope"); + ?? throw new InvalidOperationException($"Could not retrieve an {nameof(IOpenIddictTokenManager)} service from the current scope"); await tokenManager.PruneAsync(threshold); } catch (Exception exception) @@ -49,7 +49,7 @@ public class OpenIddictCleanupJob : IRecurringBackgroundJob try { IOpenIddictAuthorizationManager authorizationManager = scope.ServiceProvider.GetService() - ?? throw new ConfigurationErrorsException($"Could not retrieve an {nameof(IOpenIddictAuthorizationManager)} service from the current scope"); + ?? throw new InvalidOperationException($"Could not retrieve an {nameof(IOpenIddictAuthorizationManager)} service from the current scope"); await authorizationManager.PruneAsync(threshold); } catch (Exception exception)