Moves more cache classes

This commit is contained in:
Shannon
2019-11-07 18:50:14 +11:00
committed by Bjarke Berg
parent 93c75372e7
commit 0463f2a43b
8 changed files with 8 additions and 20 deletions

View File

@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Caching;
namespace Umbraco.Core.Cache
{
@@ -15,8 +14,6 @@ namespace Umbraco.Core.Cache
Func<T> getCacheItem,
TimeSpan? timeout,
bool isSliding = false,
CacheItemPriority priority = CacheItemPriority.Normal,
CacheItemRemovedCallback removedCallback = null,
string[] dependentFiles = null)
{
var result = provider.Get(cacheKey, () => getCacheItem(), timeout, isSliding, dependentFiles);
@@ -28,8 +25,6 @@ namespace Umbraco.Core.Cache
Func<T> getCacheItem,
TimeSpan? timeout = null,
bool isSliding = false,
CacheItemPriority priority = CacheItemPriority.Normal,
CacheItemRemovedCallback removedCallback = null,
string[] dependentFiles = null)
{
provider.Insert(cacheKey, () => getCacheItem(), timeout, isSliding, dependentFiles);

View File

@@ -17,24 +17,24 @@ namespace Umbraco.Core.Cache
/// <param name="cacheFactory"></param>
protected AppPolicedCacheDictionary(Func<TKey, IAppPolicyCache> cacheFactory)
{
CacheFactory = cacheFactory;
_cacheFactory = cacheFactory;
}
/// <summary>
/// Gets the internal cache factory, for tests only!
/// </summary>
internal readonly Func<TKey, IAppPolicyCache> CacheFactory;
private readonly Func<TKey, IAppPolicyCache> _cacheFactory;
/// <summary>
/// Gets or creates a cache.
/// </summary>
public IAppPolicyCache GetOrCreate(TKey key)
=> _caches.GetOrAdd(key, k => CacheFactory(k));
=> _caches.GetOrAdd(key, k => _cacheFactory(k));
/// <summary>
/// Tries to get a cache.
/// </summary>
public Attempt<IAppPolicyCache> Get(TKey key)
protected Attempt<IAppPolicyCache> Get(TKey key)
=> _caches.TryGetValue(key, out var cache) ? Attempt.Succeed(cache) : Attempt.Fail<IAppPolicyCache>();
/// <summary>
@@ -56,7 +56,7 @@ namespace Umbraco.Core.Cache
/// <summary>
/// Clears a cache.
/// </summary>
public void ClearCache(TKey key)
protected void ClearCache(TKey key)
{
if (_caches.TryGetValue(key, out var cache))
cache.Clear();
@@ -71,4 +71,4 @@ namespace Umbraco.Core.Cache
cache.Clear();
}
}
}
}

View File

@@ -5,7 +5,7 @@ using Umbraco.Core.Scoping;
namespace Umbraco.Core.Cache
{
internal interface IRepositoryCachePolicy<TEntity, TId>
public interface IRepositoryCachePolicy<TEntity, TId>
where TEntity : class, IEntity
{
/// <summary>

View File

@@ -5,7 +5,7 @@ using Umbraco.Core.Models.Entities;
namespace Umbraco.Core.Cache
{
internal class NoCacheRepositoryCachePolicy<TEntity, TId> : IRepositoryCachePolicy<TEntity, TId>
public class NoCacheRepositoryCachePolicy<TEntity, TId> : IRepositoryCachePolicy<TEntity, TId>
where TEntity : class, IEntity
{
private NoCacheRepositoryCachePolicy() { }

View File

@@ -124,10 +124,8 @@
<DependentUpon>Constants.cs</DependentUpon>
</Compile>
-->
<Compile Include="Cache\AppPolicedCacheDictionary.cs" />
<Compile Include="Compose\AuditEventsComponent.cs" />
<Compile Include="Cache\AppCaches.cs" />
<Compile Include="Cache\AppCacheExtensions.cs" />
<Compile Include="Cache\CacheRefresherBase.cs" />
<Compile Include="Cache\CacheRefresherCollection.cs" />
<Compile Include="Cache\CacheRefresherCollectionBuilder.cs" />
@@ -139,10 +137,7 @@
<Compile Include="Cache\FullDataSetRepositoryCachePolicy.cs" />
<Compile Include="Cache\HttpRequestAppCache.cs" />
<Compile Include="Cache\WebCachingAppCache.cs" />
<Compile Include="Cache\IsolatedCaches.cs" />
<Compile Include="Cache\JsonCacheRefresherBase.cs" />
<Compile Include="Cache\NoCacheRepositoryCachePolicy.cs" />
<Compile Include="Cache\NoAppCache.cs" />
<Compile Include="Cache\ObjectCacheAppCache.cs" />
<Compile Include="Cache\PayloadCacheRefresherBase.cs" />
<Compile Include="Cache\RepositoryCachePolicyBase.cs" />

View File

@@ -1,6 +1,5 @@
using System;
using System.Web;
using System.Web.Caching;
using System.Web.Mvc;
using System.Web.Mvc.Html;
using Umbraco.Core.Cache;
@@ -46,7 +45,6 @@ namespace Umbraco.Web
return appCaches.RuntimeCache.GetCacheItem<IHtmlString>(
PartialViewCacheKey + cacheKey,
() => htmlHelper.Partial(partialViewName, model, viewData),
priority: CacheItemPriority.NotRemovable, //not removable, the same as macros (apparently issue #27610)
timeout: new TimeSpan(0, 0, 0, cachedSeconds));
}