2012-10-31 11:36:22 +06:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Text;
|
2013-03-16 08:47:55 +06:00
|
|
|
|
using System.Text.RegularExpressions;
|
2012-10-31 11:36:22 +06:00
|
|
|
|
using System.Web;
|
|
|
|
|
|
using System.Web.Caching;
|
2013-03-23 04:01:52 +06:00
|
|
|
|
using Umbraco.Core.Cache;
|
2012-10-31 11:36:22 +06:00
|
|
|
|
using Umbraco.Core.Logging;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Umbraco.Core
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Class that is exposed by the ApplicationContext for application wide caching purposes
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <remarks>
|
|
|
|
|
|
/// This class may be opened publicly at some point but needs a review of what is absoletely necessary.
|
|
|
|
|
|
/// </remarks>
|
2013-03-23 04:01:52 +06:00
|
|
|
|
public class CacheHelper //: CacheProviderBase
|
2012-10-31 11:36:22 +06:00
|
|
|
|
{
|
2013-03-23 04:01:52 +06:00
|
|
|
|
private readonly bool _enableCache;
|
|
|
|
|
|
private readonly HttpRuntimeCacheProvider _httpCache;
|
|
|
|
|
|
private readonly NullCacheProvider _nullCache = new NullCacheProvider();
|
2012-10-31 11:36:22 +06:00
|
|
|
|
|
|
|
|
|
|
public CacheHelper(System.Web.Caching.Cache cache)
|
2013-03-23 04:01:52 +06:00
|
|
|
|
: this(cache, true)
|
2012-10-31 11:36:22 +06:00
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2013-03-23 04:01:52 +06:00
|
|
|
|
internal CacheHelper(System.Web.Caching.Cache cache, bool enableCache)
|
|
|
|
|
|
{
|
|
|
|
|
|
_httpCache = new HttpRuntimeCacheProvider(cache);
|
|
|
|
|
|
_enableCache = enableCache;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2012-10-31 11:36:22 +06:00
|
|
|
|
public void ClearAllCache()
|
|
|
|
|
|
{
|
2013-03-23 04:01:52 +06:00
|
|
|
|
if (!_enableCache)
|
|
|
|
|
|
{
|
|
|
|
|
|
_nullCache.ClearAllCache();
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
_httpCache.ClearAllCache();
|
|
|
|
|
|
}
|
2012-10-31 11:36:22 +06:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Clears the item in umbraco's runtime cache with the given key
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="key">Key</param>
|
|
|
|
|
|
public void ClearCacheItem(string key)
|
|
|
|
|
|
{
|
2013-03-23 04:01:52 +06:00
|
|
|
|
if (!_enableCache)
|
|
|
|
|
|
{
|
|
|
|
|
|
_nullCache.ClearCacheItem(key);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
2012-10-31 11:36:22 +06:00
|
|
|
|
{
|
2013-03-23 04:01:52 +06:00
|
|
|
|
_httpCache.ClearCacheItem(key);
|
2012-10-31 11:36:22 +06:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Clears all objects in the System.Web.Cache with the System.Type name as the
|
|
|
|
|
|
/// input parameter. (using [object].GetType())
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="typeName">The name of the System.Type which should be cleared from cache ex "System.Xml.XmlDocument"</param>
|
|
|
|
|
|
public void ClearCacheObjectTypes(string typeName)
|
|
|
|
|
|
{
|
2013-03-23 04:01:52 +06:00
|
|
|
|
if (!_enableCache)
|
2012-10-31 11:36:22 +06:00
|
|
|
|
{
|
2013-03-23 04:01:52 +06:00
|
|
|
|
_nullCache.ClearCacheObjectTypes(typeName);
|
2012-10-31 11:36:22 +06:00
|
|
|
|
}
|
2013-03-23 04:01:52 +06:00
|
|
|
|
else
|
2012-10-31 11:36:22 +06:00
|
|
|
|
{
|
2013-03-23 04:01:52 +06:00
|
|
|
|
_httpCache.ClearCacheObjectTypes(typeName);
|
2012-10-31 11:36:22 +06:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2013-03-12 22:58:21 +04:00
|
|
|
|
/// Clears all objects in the System.Web.Cache with the System.Type specified
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public void ClearCacheObjectTypes<T>()
|
|
|
|
|
|
{
|
2013-03-23 04:01:52 +06:00
|
|
|
|
if (!_enableCache)
|
2013-03-12 22:58:21 +04:00
|
|
|
|
{
|
2013-03-23 04:01:52 +06:00
|
|
|
|
_nullCache.ClearCacheObjectTypes<T>();
|
2013-03-12 22:58:21 +04:00
|
|
|
|
}
|
2013-03-23 04:01:52 +06:00
|
|
|
|
else
|
2013-03-12 22:58:21 +04:00
|
|
|
|
{
|
2013-03-23 04:01:52 +06:00
|
|
|
|
_httpCache.ClearCacheObjectTypes<T>();
|
2013-03-12 22:58:21 +04:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2012-10-31 11:36:22 +06:00
|
|
|
|
/// Clears all cache items that starts with the key passed.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="keyStartsWith">The start of the key</param>
|
|
|
|
|
|
public void ClearCacheByKeySearch(string keyStartsWith)
|
2013-03-12 22:58:21 +04:00
|
|
|
|
{
|
2013-03-23 04:01:52 +06:00
|
|
|
|
if (!_enableCache)
|
|
|
|
|
|
{
|
|
|
|
|
|
_nullCache.ClearCacheByKeySearch(keyStartsWith);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
_httpCache.ClearCacheByKeySearch(keyStartsWith);
|
|
|
|
|
|
}
|
2013-03-12 22:58:21 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
2013-03-16 08:47:55 +06:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Clears all cache items that have a key that matches the regular expression
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="regexString"></param>
|
|
|
|
|
|
public void ClearCacheByKeyExpression(string regexString)
|
|
|
|
|
|
{
|
2013-03-23 04:01:52 +06:00
|
|
|
|
if (!_enableCache)
|
|
|
|
|
|
{
|
|
|
|
|
|
_nullCache.ClearCacheByKeyExpression(regexString);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
2013-03-16 08:47:55 +06:00
|
|
|
|
{
|
2013-03-23 04:01:52 +06:00
|
|
|
|
_httpCache.ClearCacheByKeyExpression(regexString);
|
2013-03-16 08:47:55 +06:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2013-03-22 04:34:57 +06:00
|
|
|
|
public IEnumerable<T> GetCacheItemsByKeySearch<T>(string keyStartsWith)
|
|
|
|
|
|
{
|
2013-03-23 04:01:52 +06:00
|
|
|
|
if (!_enableCache)
|
|
|
|
|
|
{
|
|
|
|
|
|
return _nullCache.GetCacheItemsByKeySearch<T>(keyStartsWith);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
return _httpCache.GetCacheItemsByKeySearch<T>(keyStartsWith);
|
|
|
|
|
|
}
|
2013-03-22 04:34:57 +06:00
|
|
|
|
}
|
|
|
|
|
|
|
2013-03-12 22:58:21 +04:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Returns a cache item by key, does not update the cache if it isn't there.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <typeparam name="TT"></typeparam>
|
|
|
|
|
|
/// <param name="cacheKey"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public TT GetCacheItem<TT>(string cacheKey)
|
|
|
|
|
|
{
|
2013-03-23 04:01:52 +06:00
|
|
|
|
if (!_enableCache)
|
|
|
|
|
|
{
|
|
|
|
|
|
return _nullCache.GetCacheItem<TT>(cacheKey);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
2013-03-12 22:58:21 +04:00
|
|
|
|
{
|
2013-03-23 04:01:52 +06:00
|
|
|
|
return _httpCache.GetCacheItem<TT>(cacheKey);
|
2013-03-12 22:58:21 +04:00
|
|
|
|
}
|
2012-10-31 11:36:22 +06:00
|
|
|
|
}
|
2013-02-06 09:53:13 +06:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Gets (and adds if necessary) an item from the cache with all of the default parameters
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <typeparam name="TT"></typeparam>
|
|
|
|
|
|
/// <param name="cacheKey"></param>
|
|
|
|
|
|
/// <param name="getCacheItem"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public TT GetCacheItem<TT>(string cacheKey, Func<TT> getCacheItem)
|
|
|
|
|
|
{
|
2013-03-23 04:01:52 +06:00
|
|
|
|
if (!_enableCache)
|
|
|
|
|
|
{
|
|
|
|
|
|
return _nullCache.GetCacheItem<TT>(cacheKey, getCacheItem);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
return _httpCache.GetCacheItem<TT>(cacheKey, getCacheItem);
|
|
|
|
|
|
}
|
2013-02-06 09:53:13 +06:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Gets (and adds if necessary) an item from the cache with the specified absolute expiration date (from NOW)
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <typeparam name="TT"></typeparam>
|
|
|
|
|
|
/// <param name="cacheKey"></param>
|
2013-03-12 22:58:21 +04:00
|
|
|
|
/// <param name="timeout">This will set an absolute expiration from now until the timeout</param>
|
2013-02-06 09:53:13 +06:00
|
|
|
|
/// <param name="getCacheItem"></param>
|
|
|
|
|
|
/// <returns></returns>
|
2012-10-31 11:36:22 +06:00
|
|
|
|
public TT GetCacheItem<TT>(string cacheKey,
|
|
|
|
|
|
TimeSpan timeout, Func<TT> getCacheItem)
|
|
|
|
|
|
{
|
2013-03-23 04:01:52 +06:00
|
|
|
|
if (!_enableCache)
|
|
|
|
|
|
{
|
|
|
|
|
|
return _nullCache.GetCacheItem<TT>(cacheKey, timeout, getCacheItem);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
return _httpCache.GetCacheItem<TT>(cacheKey, timeout, getCacheItem);
|
|
|
|
|
|
}
|
2012-10-31 11:36:22 +06:00
|
|
|
|
}
|
|
|
|
|
|
|
2013-03-12 22:58:21 +04:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Gets (and adds if necessary) an item from the cache with the specified absolute expiration date (from NOW)
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <typeparam name="TT"></typeparam>
|
|
|
|
|
|
/// <param name="cacheKey"></param>
|
|
|
|
|
|
/// <param name="refreshAction"></param>
|
|
|
|
|
|
/// <param name="timeout">This will set an absolute expiration from now until the timeout</param>
|
|
|
|
|
|
/// <param name="getCacheItem"></param>
|
|
|
|
|
|
/// <returns></returns>
|
2012-10-31 11:36:22 +06:00
|
|
|
|
public TT GetCacheItem<TT>(string cacheKey,
|
|
|
|
|
|
CacheItemRemovedCallback refreshAction, TimeSpan timeout,
|
|
|
|
|
|
Func<TT> getCacheItem)
|
|
|
|
|
|
{
|
2013-03-23 04:01:52 +06:00
|
|
|
|
if (!_enableCache)
|
|
|
|
|
|
{
|
|
|
|
|
|
return _nullCache.GetCacheItem<TT>(cacheKey, refreshAction, timeout, getCacheItem);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
return _httpCache.GetCacheItem<TT>(cacheKey, refreshAction, timeout, getCacheItem);
|
|
|
|
|
|
}
|
2012-10-31 11:36:22 +06:00
|
|
|
|
}
|
|
|
|
|
|
|
2013-03-12 22:58:21 +04:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Gets (and adds if necessary) an item from the cache with the specified absolute expiration date (from NOW)
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <typeparam name="TT"></typeparam>
|
|
|
|
|
|
/// <param name="cacheKey"></param>
|
|
|
|
|
|
/// <param name="priority"></param>
|
|
|
|
|
|
/// <param name="refreshAction"></param>
|
|
|
|
|
|
/// <param name="timeout">This will set an absolute expiration from now until the timeout</param>
|
|
|
|
|
|
/// <param name="getCacheItem"></param>
|
|
|
|
|
|
/// <returns></returns>
|
2012-10-31 11:36:22 +06:00
|
|
|
|
public TT GetCacheItem<TT>(string cacheKey,
|
|
|
|
|
|
CacheItemPriority priority, CacheItemRemovedCallback refreshAction, TimeSpan timeout,
|
|
|
|
|
|
Func<TT> getCacheItem)
|
|
|
|
|
|
{
|
2013-03-23 04:01:52 +06:00
|
|
|
|
if (!_enableCache)
|
|
|
|
|
|
{
|
|
|
|
|
|
return _nullCache.GetCacheItem<TT>(cacheKey, priority, refreshAction, timeout, getCacheItem);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
return _httpCache.GetCacheItem<TT>(cacheKey, priority, refreshAction, timeout, getCacheItem);
|
|
|
|
|
|
}
|
2012-10-31 11:36:22 +06:00
|
|
|
|
}
|
|
|
|
|
|
|
2013-03-12 22:58:21 +04:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Gets (and adds if necessary) an item from the cache with the specified absolute expiration date (from NOW)
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <typeparam name="TT"></typeparam>
|
|
|
|
|
|
/// <param name="cacheKey"></param>
|
|
|
|
|
|
/// <param name="priority"></param>
|
|
|
|
|
|
/// <param name="refreshAction"></param>
|
|
|
|
|
|
/// <param name="cacheDependency"></param>
|
|
|
|
|
|
/// <param name="timeout">This will set an absolute expiration from now until the timeout</param>
|
|
|
|
|
|
/// <param name="getCacheItem"></param>
|
|
|
|
|
|
/// <returns></returns>
|
2012-10-31 11:36:22 +06:00
|
|
|
|
public TT GetCacheItem<TT>(string cacheKey,
|
|
|
|
|
|
CacheItemPriority priority,
|
|
|
|
|
|
CacheItemRemovedCallback refreshAction,
|
|
|
|
|
|
CacheDependency cacheDependency,
|
|
|
|
|
|
TimeSpan timeout,
|
|
|
|
|
|
Func<TT> getCacheItem)
|
|
|
|
|
|
{
|
2013-03-23 04:01:52 +06:00
|
|
|
|
if (!_enableCache)
|
|
|
|
|
|
{
|
|
|
|
|
|
return _nullCache.GetCacheItem<TT>(cacheKey, priority, refreshAction, cacheDependency, timeout, getCacheItem);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
return _httpCache.GetCacheItem<TT>(cacheKey, priority, refreshAction, cacheDependency, timeout, getCacheItem);
|
|
|
|
|
|
}
|
2012-10-31 11:36:22 +06:00
|
|
|
|
}
|
2013-04-03 22:34:40 +06:00
|
|
|
|
|
2013-04-03 23:39:51 +06:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Gets (and adds if necessary) an item from the cache
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <typeparam name="TT"></typeparam>
|
|
|
|
|
|
/// <param name="cacheKey"></param>
|
|
|
|
|
|
/// <param name="priority"></param>
|
|
|
|
|
|
/// <param name="cacheDependency"></param>
|
|
|
|
|
|
/// <param name="getCacheItem"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public TT GetCacheItem<TT>(string cacheKey,
|
|
|
|
|
|
CacheItemPriority priority,
|
|
|
|
|
|
CacheDependency cacheDependency,
|
|
|
|
|
|
Func<TT> getCacheItem)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!_enableCache)
|
|
|
|
|
|
{
|
|
|
|
|
|
return _nullCache.GetCacheItem<TT>(cacheKey, priority, null, cacheDependency, null, getCacheItem);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
return _httpCache.GetCacheItem<TT>(cacheKey, priority, null, cacheDependency, null, getCacheItem);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2013-04-03 22:34:40 +06:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Inserts an item into the cache, if it already exists in the cache it will be replaced
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <typeparam name="T"></typeparam>
|
|
|
|
|
|
/// <param name="cacheKey"></param>
|
|
|
|
|
|
/// <param name="priority"></param>
|
|
|
|
|
|
/// <param name="getCacheItem"></param>
|
|
|
|
|
|
public void InsertCacheItem<T>(string cacheKey,
|
|
|
|
|
|
CacheItemPriority priority,
|
|
|
|
|
|
Func<T> getCacheItem)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!_enableCache)
|
|
|
|
|
|
{
|
|
|
|
|
|
_nullCache.InsertCacheItem<T>(cacheKey, priority, getCacheItem);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
_httpCache.InsertCacheItem<T>(cacheKey, priority, getCacheItem);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2013-03-23 04:01:52 +06:00
|
|
|
|
|
2013-03-12 22:58:21 +04:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Inserts an item into the cache, if it already exists in the cache it will be replaced
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <typeparam name="T"></typeparam>
|
|
|
|
|
|
/// <param name="cacheKey"></param>
|
|
|
|
|
|
/// <param name="priority"></param>
|
|
|
|
|
|
/// <param name="timeout">This will set an absolute expiration from now until the timeout</param>
|
|
|
|
|
|
/// <param name="getCacheItem"></param>
|
|
|
|
|
|
public void InsertCacheItem<T>(string cacheKey,
|
|
|
|
|
|
CacheItemPriority priority,
|
|
|
|
|
|
TimeSpan timeout,
|
|
|
|
|
|
Func<T> getCacheItem)
|
|
|
|
|
|
{
|
2013-03-23 04:01:52 +06:00
|
|
|
|
if (!_enableCache)
|
|
|
|
|
|
{
|
|
|
|
|
|
_nullCache.InsertCacheItem<T>(cacheKey, priority, timeout, getCacheItem);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
_httpCache.InsertCacheItem<T>(cacheKey, priority, timeout, getCacheItem);
|
|
|
|
|
|
}
|
2013-03-12 22:58:21 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Inserts an item into the cache, if it already exists in the cache it will be replaced
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <typeparam name="T"></typeparam>
|
|
|
|
|
|
/// <param name="cacheKey"></param>
|
|
|
|
|
|
/// <param name="priority"></param>
|
|
|
|
|
|
/// <param name="cacheDependency"></param>
|
|
|
|
|
|
/// <param name="timeout">This will set an absolute expiration from now until the timeout</param>
|
|
|
|
|
|
/// <param name="getCacheItem"></param>
|
|
|
|
|
|
public void InsertCacheItem<T>(string cacheKey,
|
|
|
|
|
|
CacheItemPriority priority,
|
|
|
|
|
|
CacheDependency cacheDependency,
|
|
|
|
|
|
TimeSpan timeout,
|
|
|
|
|
|
Func<T> getCacheItem)
|
|
|
|
|
|
{
|
2013-03-23 04:01:52 +06:00
|
|
|
|
if (!_enableCache)
|
|
|
|
|
|
{
|
|
|
|
|
|
_nullCache.InsertCacheItem<T>(cacheKey, priority, cacheDependency, timeout, getCacheItem);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
_httpCache.InsertCacheItem<T>(cacheKey, priority, cacheDependency, timeout, getCacheItem);
|
|
|
|
|
|
}
|
2013-03-12 22:58:21 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Inserts an item into the cache, if it already exists in the cache it will be replaced
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <typeparam name="T"></typeparam>
|
|
|
|
|
|
/// <param name="cacheKey"></param>
|
|
|
|
|
|
/// <param name="priority"></param>
|
|
|
|
|
|
/// <param name="refreshAction"></param>
|
|
|
|
|
|
/// <param name="cacheDependency"></param>
|
|
|
|
|
|
/// <param name="timeout">This will set an absolute expiration from now until the timeout</param>
|
|
|
|
|
|
/// <param name="getCacheItem"></param>
|
|
|
|
|
|
public void InsertCacheItem<T>(string cacheKey,
|
|
|
|
|
|
CacheItemPriority priority,
|
|
|
|
|
|
CacheItemRemovedCallback refreshAction,
|
|
|
|
|
|
CacheDependency cacheDependency,
|
|
|
|
|
|
TimeSpan? timeout,
|
|
|
|
|
|
Func<T> getCacheItem)
|
|
|
|
|
|
{
|
2013-03-23 04:01:52 +06:00
|
|
|
|
if (!_enableCache)
|
|
|
|
|
|
{
|
|
|
|
|
|
_nullCache.InsertCacheItem<T>(cacheKey, priority, refreshAction, cacheDependency, timeout, getCacheItem);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
_httpCache.InsertCacheItem<T>(cacheKey, priority, refreshAction, cacheDependency, timeout, getCacheItem);
|
|
|
|
|
|
}
|
2013-03-12 22:58:21 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2012-10-31 11:36:22 +06:00
|
|
|
|
|
|
|
|
|
|
}
|