From fdda90c2bfa159733d25d76110efef471295f902 Mon Sep 17 00:00:00 2001 From: Shannon Date: Thu, 7 Nov 2019 19:39:20 +1100 Subject: [PATCH] Installs runtime cache nuget into abstractions, moves more cache classes and preps AppCaches to not rely on system.web. --- .../Cache/CacheRefresherEventArgs.cs | 0 .../Cache/DeepCloneAppCache.cs | 4 ++-- .../Cache/RepositoryCachePolicyOptions.cs | 2 +- .../Umbraco.Abstractions.csproj | 4 ++++ src/Umbraco.Core/Cache/AppCaches.cs | 18 ------------------ .../Cache/DefaultRepositoryCachePolicy.cs | 2 +- .../Cache/RepositoryCachePolicyBase.cs | 2 +- src/Umbraco.Core/Umbraco.Core.csproj | 7 ++----- .../ServerRegistrationRepositoryTest.cs | 2 +- src/Umbraco.Tests/Runtimes/StandaloneTests.cs | 2 +- 10 files changed, 13 insertions(+), 30 deletions(-) rename src/{Umbraco.Core => Umbraco.Abstractions}/Cache/CacheRefresherEventArgs.cs (100%) rename src/{Umbraco.Core => Umbraco.Abstractions}/Cache/DeepCloneAppCache.cs (98%) rename src/{Umbraco.Core => Umbraco.Abstractions}/Cache/RepositoryCachePolicyOptions.cs (97%) diff --git a/src/Umbraco.Core/Cache/CacheRefresherEventArgs.cs b/src/Umbraco.Abstractions/Cache/CacheRefresherEventArgs.cs similarity index 100% rename from src/Umbraco.Core/Cache/CacheRefresherEventArgs.cs rename to src/Umbraco.Abstractions/Cache/CacheRefresherEventArgs.cs diff --git a/src/Umbraco.Core/Cache/DeepCloneAppCache.cs b/src/Umbraco.Abstractions/Cache/DeepCloneAppCache.cs similarity index 98% rename from src/Umbraco.Core/Cache/DeepCloneAppCache.cs rename to src/Umbraco.Abstractions/Cache/DeepCloneAppCache.cs index 90367e0627..452f897372 100644 --- a/src/Umbraco.Core/Cache/DeepCloneAppCache.cs +++ b/src/Umbraco.Abstractions/Cache/DeepCloneAppCache.cs @@ -11,7 +11,7 @@ namespace Umbraco.Core.Cache /// instance, and ensuring that all inserts and returns are deep cloned copies of the cache item, /// when the item is deep-cloneable. /// - internal class DeepCloneAppCache : IAppPolicyCache + public class DeepCloneAppCache : IAppPolicyCache { /// /// Initializes a new instance of the class. @@ -29,7 +29,7 @@ namespace Umbraco.Core.Cache /// /// Gets the inner cache. /// - public IAppPolicyCache InnerCache { get; } + private IAppPolicyCache InnerCache { get; } /// public object Get(string key) diff --git a/src/Umbraco.Core/Cache/RepositoryCachePolicyOptions.cs b/src/Umbraco.Abstractions/Cache/RepositoryCachePolicyOptions.cs similarity index 97% rename from src/Umbraco.Core/Cache/RepositoryCachePolicyOptions.cs rename to src/Umbraco.Abstractions/Cache/RepositoryCachePolicyOptions.cs index 72baa05564..06095f058d 100644 --- a/src/Umbraco.Core/Cache/RepositoryCachePolicyOptions.cs +++ b/src/Umbraco.Abstractions/Cache/RepositoryCachePolicyOptions.cs @@ -5,7 +5,7 @@ namespace Umbraco.Core.Cache /// /// Specifies how a repository cache policy should cache entities. /// - internal class RepositoryCachePolicyOptions + public class RepositoryCachePolicyOptions { /// /// Ctor - sets GetAllCacheValidateCount = true diff --git a/src/Umbraco.Abstractions/Umbraco.Abstractions.csproj b/src/Umbraco.Abstractions/Umbraco.Abstractions.csproj index 4a3654ede6..a5e5a94520 100644 --- a/src/Umbraco.Abstractions/Umbraco.Abstractions.csproj +++ b/src/Umbraco.Abstractions/Umbraco.Abstractions.csproj @@ -6,4 +6,8 @@ Umbraco.Core + + + + diff --git a/src/Umbraco.Core/Cache/AppCaches.cs b/src/Umbraco.Core/Cache/AppCaches.cs index fbfc4c8c82..5e8c460ae4 100644 --- a/src/Umbraco.Core/Cache/AppCaches.cs +++ b/src/Umbraco.Core/Cache/AppCaches.cs @@ -1,5 +1,4 @@ using System; -using System.Web; namespace Umbraco.Core.Cache { @@ -8,23 +7,6 @@ namespace Umbraco.Core.Cache /// public class AppCaches { - /// - /// Initializes a new instance of the for use in a web application. - /// - public AppCaches() - : this(HttpRuntime.Cache) - { } - - /// - /// Initializes a new instance of the for use in a web application. - /// - public AppCaches(System.Web.Caching.Cache cache) - : this( - new WebCachingAppCache(cache), - new HttpRequestAppCache(), - new IsolatedCaches(t => new ObjectCacheAppCache())) - { } - /// /// Initializes a new instance of the with cache providers. /// diff --git a/src/Umbraco.Core/Cache/DefaultRepositoryCachePolicy.cs b/src/Umbraco.Core/Cache/DefaultRepositoryCachePolicy.cs index c11309c827..e4102e8684 100644 --- a/src/Umbraco.Core/Cache/DefaultRepositoryCachePolicy.cs +++ b/src/Umbraco.Core/Cache/DefaultRepositoryCachePolicy.cs @@ -17,7 +17,7 @@ namespace Umbraco.Core.Cache /// If options.GetAllCacheAllowZeroCount then a 'zero-count' array is cached when GetAll finds nothing. /// If options.GetAllCacheValidateCount then we check against the db when getting many entities. /// - internal class DefaultRepositoryCachePolicy : RepositoryCachePolicyBase + public class DefaultRepositoryCachePolicy : RepositoryCachePolicyBase where TEntity : class, IEntity { private static readonly TEntity[] EmptyEntities = new TEntity[0]; // const diff --git a/src/Umbraco.Core/Cache/RepositoryCachePolicyBase.cs b/src/Umbraco.Core/Cache/RepositoryCachePolicyBase.cs index 27fe4e3035..33258cbf06 100644 --- a/src/Umbraco.Core/Cache/RepositoryCachePolicyBase.cs +++ b/src/Umbraco.Core/Cache/RepositoryCachePolicyBase.cs @@ -10,7 +10,7 @@ namespace Umbraco.Core.Cache /// /// The type of the entity. /// The type of the identifier. - internal abstract class RepositoryCachePolicyBase : IRepositoryCachePolicy + public abstract class RepositoryCachePolicyBase : IRepositoryCachePolicy where TEntity : class, IEntity { private readonly IAppPolicyCache _globalCache; diff --git a/src/Umbraco.Core/Umbraco.Core.csproj b/src/Umbraco.Core/Umbraco.Core.csproj index 9a2040fe00..190c5f7434 100755 --- a/src/Umbraco.Core/Umbraco.Core.csproj +++ b/src/Umbraco.Core/Umbraco.Core.csproj @@ -124,16 +124,14 @@ Constants.cs --> + + - - - - @@ -141,7 +139,6 @@ - diff --git a/src/Umbraco.Tests/Persistence/Repositories/ServerRegistrationRepositoryTest.cs b/src/Umbraco.Tests/Persistence/Repositories/ServerRegistrationRepositoryTest.cs index e2fc4b4705..b84a79b3d1 100644 --- a/src/Umbraco.Tests/Persistence/Repositories/ServerRegistrationRepositoryTest.cs +++ b/src/Umbraco.Tests/Persistence/Repositories/ServerRegistrationRepositoryTest.cs @@ -22,7 +22,7 @@ namespace Umbraco.Tests.Persistence.Repositories { base.SetUp(); - _appCaches = new AppCaches(); + _appCaches = AppCaches.Disabled; CreateTestData(); } diff --git a/src/Umbraco.Tests/Runtimes/StandaloneTests.cs b/src/Umbraco.Tests/Runtimes/StandaloneTests.cs index 60e86ad5b0..b1e2f24564 100644 --- a/src/Umbraco.Tests/Runtimes/StandaloneTests.cs +++ b/src/Umbraco.Tests/Runtimes/StandaloneTests.cs @@ -59,7 +59,7 @@ namespace Umbraco.Tests.Runtimes var logger = new ConsoleLogger(new MessageTemplates()); var profiler = new LogProfiler(logger); var profilingLogger = new ProfilingLogger(logger, profiler); - var appCaches = new AppCaches(); // FIXME: has HttpRuntime stuff? + var appCaches = AppCaches.Disabled; var databaseFactory = new UmbracoDatabaseFactory(logger, new Lazy(() => factory.GetInstance())); var typeLoader = new TypeLoader(appCaches.RuntimeCache, IOHelper.MapPath("~/App_Data/TEMP"), profilingLogger); var mainDom = new SimpleMainDom();