2012-10-31 11:36:22 +06:00
using System ;
using System.Collections ;
2016-01-06 13:48:03 +01:00
using System.Collections.Concurrent ;
2012-10-31 11:36:22 +06:00
using System.Collections.Generic ;
2016-01-06 18:08:14 +01:00
using System.ComponentModel ;
2012-10-31 11:36:22 +06:00
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>
2013-05-13 19:31:27 -10:00
public class CacheHelper
2012-10-31 11:36:22 +06:00
{
2016-01-06 18:08:14 +01:00
private static readonly ICacheProvider NullRequestCache = new NullCacheProvider ( ) ;
private static readonly ICacheProvider NullStaticCache = new NullCacheProvider ( ) ;
private static readonly IRuntimeCacheProvider NullRuntimeCache = new NullCacheProvider ( ) ;
2017-01-20 15:06:48 +01:00
private static readonly IsolatedRuntimeCache NullIsolatedCache = new IsolatedRuntimeCache ( _ = > NullRuntimeCache ) ;
private static readonly CacheHelper NullCache = new CacheHelper ( NullRuntimeCache , NullStaticCache , NullRequestCache , NullIsolatedCache ) ;
public static CacheHelper NoCache { get { return NullCache ; } }
2016-01-06 13:48:03 +01:00
2013-08-09 11:37:57 +10:00
/// <summary>
/// Creates a cache helper with disabled caches
/// </summary>
/// <returns></returns>
/// <remarks>
/// Good for unit testing
/// </remarks>
2013-10-09 13:52:24 +11:00
public static CacheHelper CreateDisabledCacheHelper ( )
2013-05-13 19:31:27 -10:00
{
2017-01-20 15:06:48 +01:00
// do *not* return NoCache
// NoCache is a special instance that is detected by RepositoryBase and disables all cache policies
// CreateDisabledCacheHelper is used in tests to use no cache, *but* keep all cache policies
return new CacheHelper ( NullRuntimeCache , NullStaticCache , NullRequestCache , NullIsolatedCache ) ;
2013-05-13 19:31:27 -10:00
}
2013-08-09 11:37:57 +10:00
/// <summary>
/// Initializes a new instance for use in the web
/// </summary>
public CacheHelper ( )
: this (
new HttpRuntimeCacheProvider ( HttpRuntime . Cache ) ,
new StaticCacheProvider ( ) ,
2016-01-06 18:08:14 +01:00
new HttpRequestCacheProvider ( ) ,
new IsolatedRuntimeCache ( t = > new ObjectCacheRuntimeCacheProvider ( ) ) )
2013-08-09 11:37:57 +10:00
{
}
/// <summary>
/// Initializes a new instance for use in the web
/// </summary>
/// <param name="cache"></param>
public CacheHelper ( System . Web . Caching . Cache cache )
: this (
new HttpRuntimeCacheProvider ( cache ) ,
new StaticCacheProvider ( ) ,
2016-01-06 18:08:14 +01:00
new HttpRequestCacheProvider ( ) ,
new IsolatedRuntimeCache ( t = > new ObjectCacheRuntimeCacheProvider ( ) ) )
2013-08-09 11:37:57 +10:00
{
}
2016-01-06 18:08:14 +01:00
[Obsolete("Use the constructor the specifies all dependencies")]
[EditorBrowsable(EditorBrowsableState.Never)]
2013-08-09 11:37:57 +10:00
public CacheHelper (
2013-08-08 19:46:58 +10:00
IRuntimeCacheProvider httpCacheProvider ,
ICacheProvider staticCacheProvider ,
2013-08-09 11:37:57 +10:00
ICacheProvider requestCacheProvider )
2016-01-06 18:08:14 +01:00
: this ( httpCacheProvider , staticCacheProvider , requestCacheProvider , new IsolatedRuntimeCache ( t = > new ObjectCacheRuntimeCacheProvider ( ) ) )
2013-08-09 11:37:57 +10:00
{
}
2016-01-06 18:08:14 +01:00
/// <summary>
/// Initializes a new instance based on the provided providers
/// </summary>
/// <param name="httpCacheProvider"></param>
/// <param name="staticCacheProvider"></param>
/// <param name="requestCacheProvider"></param>
/// <param name="isolatedCacheManager"></param>
public CacheHelper (
2013-08-09 11:37:57 +10:00
IRuntimeCacheProvider httpCacheProvider ,
ICacheProvider staticCacheProvider ,
2016-01-06 18:08:14 +01:00
ICacheProvider requestCacheProvider ,
IsolatedRuntimeCache isolatedCacheManager )
2013-05-13 19:31:27 -10:00
{
2016-01-06 18:08:14 +01:00
if ( httpCacheProvider = = null ) throw new ArgumentNullException ( "httpCacheProvider" ) ;
if ( staticCacheProvider = = null ) throw new ArgumentNullException ( "staticCacheProvider" ) ;
if ( requestCacheProvider = = null ) throw new ArgumentNullException ( "requestCacheProvider" ) ;
if ( isolatedCacheManager = = null ) throw new ArgumentNullException ( "isolatedCacheManager" ) ;
2016-01-22 16:37:47 +01:00
RuntimeCache = httpCacheProvider ;
StaticCache = staticCacheProvider ;
RequestCache = requestCacheProvider ;
IsolatedRuntimeCache = isolatedCacheManager ;
2013-05-13 19:31:27 -10:00
}
2013-08-08 19:46:58 +10:00
/// <summary>
2013-08-09 11:16:10 +10:00
/// Returns the current Request cache
2013-08-08 19:46:58 +10:00
/// </summary>
2016-01-22 16:37:47 +01:00
public ICacheProvider RequestCache { get ; internal set ; }
2016-01-06 18:08:14 +01:00
2013-08-08 19:46:58 +10:00
/// <summary>
2013-08-09 11:16:10 +10:00
/// Returns the current Runtime cache
2013-08-08 19:46:58 +10:00
/// </summary>
2016-01-22 16:37:47 +01:00
public ICacheProvider StaticCache { get ; internal set ; }
2013-08-08 19:46:58 +10:00
/// <summary>
2013-08-09 11:16:10 +10:00
/// Returns the current Runtime cache
2013-08-08 19:46:58 +10:00
/// </summary>
2016-01-22 16:37:47 +01:00
public IRuntimeCacheProvider RuntimeCache { get ; internal set ; }
2016-01-06 18:08:14 +01:00
/// <summary>
/// Returns the current Isolated Runtime cache manager
/// </summary>
2016-01-22 16:37:47 +01:00
public IsolatedRuntimeCache IsolatedRuntimeCache { get ; internal set ; }
#region Legacy Runtime / Http Cache accessors
2013-05-13 19:31:27 -10:00
/// <summary>
/// Clears the item in umbraco's runtime cache
/// </summary>
2013-08-09 11:16:10 +10:00
[Obsolete("Do not use this method, access the runtime cache from the RuntimeCache property")]
2016-01-06 18:08:14 +01:00
[EditorBrowsable(EditorBrowsableState.Never)]
2012-10-31 11:36:22 +06:00
public void ClearAllCache ( )
2013-05-13 19:31:27 -10:00
{
2016-01-22 16:37:47 +01:00
RuntimeCache . ClearAllCache ( ) ;
IsolatedRuntimeCache . ClearAllCaches ( ) ;
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>
2013-08-09 11:16:10 +10:00
[Obsolete("Do not use this method, access the runtime cache from the RuntimeCache property")]
2016-01-06 18:08:14 +01:00
[EditorBrowsable(EditorBrowsableState.Never)]
2012-10-31 11:36:22 +06:00
public void ClearCacheItem ( string key )
{
2016-01-22 16:37:47 +01:00
RuntimeCache . 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>
2013-08-09 11:16:10 +10:00
[Obsolete("Do not use this method, access the runtime cache from the RuntimeCache property")]
2012-10-31 11:36:22 +06:00
public void ClearCacheObjectTypes ( string typeName )
{
2016-01-22 16:37:47 +01:00
RuntimeCache . 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>
2013-08-09 11:16:10 +10:00
[Obsolete("Do not use this method, access the runtime cache from the RuntimeCache property")]
2016-01-06 18:08:14 +01:00
[EditorBrowsable(EditorBrowsableState.Never)]
2013-05-13 19:31:27 -10:00
public void ClearCacheObjectTypes < T > ( )
{
2016-01-22 16:37:47 +01:00
RuntimeCache . ClearCacheObjectTypes < T > ( ) ;
2013-05-13 19:31:27 -10:00
}
2013-03-12 22:58:21 +04:00
2013-05-13 19:31:27 -10: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>
2013-08-09 11:16:10 +10:00
[Obsolete("Do not use this method, access the runtime cache from the RuntimeCache property")]
2016-01-06 18:08:14 +01:00
[EditorBrowsable(EditorBrowsableState.Never)]
2012-10-31 11:36:22 +06:00
public void ClearCacheByKeySearch ( string keyStartsWith )
2013-05-13 19:31:27 -10:00
{
2016-01-22 16:37:47 +01:00
RuntimeCache . ClearCacheByKeySearch ( keyStartsWith ) ;
2013-05-13 19:31:27 -10:00
}
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>
2013-08-09 11:16:10 +10:00
[Obsolete("Do not use this method, access the runtime cache from the RuntimeCache property")]
2016-01-06 18:08:14 +01:00
[EditorBrowsable(EditorBrowsableState.Never)]
2013-05-13 19:31:27 -10:00
public void ClearCacheByKeyExpression ( string regexString )
{
2016-01-22 16:37:47 +01:00
RuntimeCache . ClearCacheByKeyExpression ( regexString ) ;
2013-05-13 19:31:27 -10:00
}
2013-03-16 08:47:55 +06:00
2013-08-09 11:16:10 +10:00
[Obsolete("Do not use this method, access the runtime cache from the RuntimeCache property")]
2016-01-06 18:08:14 +01:00
[EditorBrowsable(EditorBrowsableState.Never)]
2013-03-22 04:34:57 +06:00
public IEnumerable < T > GetCacheItemsByKeySearch < T > ( string keyStartsWith )
{
2016-01-22 16:37:47 +01:00
return RuntimeCache . GetCacheItemsByKeySearch < T > ( keyStartsWith ) ;
2013-03-22 04:34:57 +06:00
}
2013-05-13 19:31:27 -10:00
/// <summary>
2013-03-12 22:58:21 +04:00
/// 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>
2013-08-09 11:16:10 +10:00
[Obsolete("Do not use this method, access the runtime cache from the RuntimeCache property")]
2016-01-06 18:08:14 +01:00
[EditorBrowsable(EditorBrowsableState.Never)]
2013-03-12 22:58:21 +04:00
public TT GetCacheItem < TT > ( string cacheKey )
{
2016-01-22 16:37:47 +01:00
return RuntimeCache . GetCacheItem < TT > ( cacheKey ) ;
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>
2013-08-09 11:16:10 +10:00
[Obsolete("Do not use this method, access the runtime cache from the RuntimeCache property")]
2016-01-06 18:08:14 +01:00
[EditorBrowsable(EditorBrowsableState.Never)]
2013-02-06 09:53:13 +06:00
public TT GetCacheItem < TT > ( string cacheKey , Func < TT > getCacheItem )
{
2016-01-22 16:37:47 +01:00
return RuntimeCache . GetCacheItem < TT > ( cacheKey , getCacheItem ) ;
2016-01-06 18:08:14 +01:00
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>
2013-08-09 11:16:10 +10:00
[Obsolete("Do not use this method, access the runtime cache from the RuntimeCache property")]
2016-01-06 18:08:14 +01:00
[EditorBrowsable(EditorBrowsableState.Never)]
2012-10-31 11:36:22 +06:00
public TT GetCacheItem < TT > ( string cacheKey ,
TimeSpan timeout , Func < TT > getCacheItem )
{
2016-01-22 16:37:47 +01:00
return RuntimeCache . GetCacheItem < TT > ( cacheKey , getCacheItem , timeout ) ;
2016-01-06 18:08:14 +01:00
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>
2013-08-09 11:16:10 +10:00
[Obsolete("Do not use this method, access the runtime cache from the RuntimeCache property")]
2016-01-06 18:08:14 +01:00
[EditorBrowsable(EditorBrowsableState.Never)]
2012-10-31 11:36:22 +06:00
public TT GetCacheItem < TT > ( string cacheKey ,
CacheItemRemovedCallback refreshAction , TimeSpan timeout ,
Func < TT > getCacheItem )
{
2016-01-22 16:37:47 +01:00
return RuntimeCache . GetCacheItem < TT > ( cacheKey , getCacheItem , timeout , removedCallback : refreshAction ) ;
2016-01-06 18:08:14 +01:00
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>
2013-08-09 11:16:10 +10:00
[Obsolete("Do not use this method, access the runtime cache from the RuntimeCache property")]
2016-01-06 18:08:14 +01:00
[EditorBrowsable(EditorBrowsableState.Never)]
2012-10-31 11:36:22 +06:00
public TT GetCacheItem < TT > ( string cacheKey ,
CacheItemPriority priority , CacheItemRemovedCallback refreshAction , TimeSpan timeout ,
Func < TT > getCacheItem )
{
2016-01-22 16:37:47 +01:00
return RuntimeCache . GetCacheItem < TT > ( cacheKey , getCacheItem , timeout , false , priority , refreshAction ) ;
2016-01-06 18:08:14 +01:00
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>
2013-08-09 11:16:10 +10:00
[Obsolete("Do not use this method, we no longer support the caching overloads with references to CacheDependency, use the overloads specifying a file collection instead")]
2012-10-31 11:36:22 +06:00
public TT GetCacheItem < TT > ( string cacheKey ,
2013-05-13 19:31:27 -10:00
CacheItemPriority priority ,
CacheItemRemovedCallback refreshAction ,
CacheDependency cacheDependency ,
TimeSpan timeout ,
Func < TT > getCacheItem )
2012-10-31 11:36:22 +06:00
{
2016-02-04 11:01:54 +01:00
var cache = GetHttpRuntimeCacheProvider ( RuntimeCache ) ;
2016-01-06 18:08:14 +01:00
if ( cache ! = null )
2013-03-23 04:01:52 +06:00
{
2016-01-06 18:08:14 +01:00
var result = cache . GetCacheItem ( cacheKey , ( ) = > getCacheItem ( ) , timeout , false , priority , refreshAction , cacheDependency ) ;
return result = = null ? default ( TT ) : result . TryConvertTo < TT > ( ) . Result ;
2013-03-23 04:01:52 +06:00
}
2016-01-06 18:08:14 +01:00
throw new InvalidOperationException ( "Cannot use this obsoleted overload when the current provider is not of type " + typeof ( HttpRuntimeCacheProvider ) ) ;
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>
2013-08-09 11:16:10 +10:00
[Obsolete("Do not use this method, we no longer support the caching overloads with references to CacheDependency, use the overloads specifying a file collection instead")]
2013-04-03 23:39:51 +06:00
public TT GetCacheItem < TT > ( string cacheKey ,
CacheItemPriority priority ,
CacheDependency cacheDependency ,
Func < TT > getCacheItem )
{
2016-02-04 11:01:54 +01:00
var cache = GetHttpRuntimeCacheProvider ( RuntimeCache ) ;
2016-01-06 18:08:14 +01:00
if ( cache ! = null )
2013-04-03 23:39:51 +06:00
{
2016-01-06 18:08:14 +01:00
var result = cache . GetCacheItem ( cacheKey , ( ) = > getCacheItem ( ) , null , false , priority , null , cacheDependency ) ;
return result = = null ? default ( TT ) : result . TryConvertTo < TT > ( ) . Result ;
2013-04-03 23:39:51 +06:00
}
2016-01-06 18:08:14 +01:00
throw new InvalidOperationException ( "Cannot use this obsoleted overload when the current provider is not of type " + typeof ( HttpRuntimeCacheProvider ) ) ;
2013-04-03 23:39:51 +06:00
}
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>
2016-01-06 18:08:14 +01:00
[Obsolete("Do not use this method, access the runtime cache from the RuntimeCache property")]
[EditorBrowsable(EditorBrowsableState.Never)]
2013-04-03 22:34:40 +06:00
public void InsertCacheItem < T > ( string cacheKey ,
CacheItemPriority priority ,
Func < T > getCacheItem )
{
2016-01-22 16:37:47 +01:00
RuntimeCache . InsertCacheItem < T > ( cacheKey , getCacheItem , priority : priority ) ;
2016-01-06 18:08:14 +01:00
2013-04-03 22:34:40 +06:00
}
2013-05-13 19:31:27 -10: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>
2016-01-06 18:08:14 +01:00
[Obsolete("Do not use this method, access the runtime cache from the RuntimeCache property")]
[EditorBrowsable(EditorBrowsableState.Never)]
2013-03-12 22:58:21 +04:00
public void InsertCacheItem < T > ( string cacheKey ,
CacheItemPriority priority ,
TimeSpan timeout ,
Func < T > getCacheItem )
{
2016-01-22 16:37:47 +01:00
RuntimeCache . InsertCacheItem < T > ( cacheKey , getCacheItem , timeout , priority : priority ) ;
2013-03-12 22:58:21 +04:00
}
2013-05-13 19:31:27 -10: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>
2013-08-09 11:16:10 +10:00
[Obsolete("Do not use this method, we no longer support the caching overloads with references to CacheDependency, use the overloads specifying a file collection instead")]
2013-05-13 19:31:27 -10:00
public void InsertCacheItem < T > ( string cacheKey ,
CacheItemPriority priority ,
CacheDependency cacheDependency ,
TimeSpan timeout ,
Func < T > getCacheItem )
{
2016-02-04 11:01:54 +01:00
var cache = GetHttpRuntimeCacheProvider ( RuntimeCache ) ;
2016-01-06 18:08:14 +01:00
if ( cache ! = null )
2013-03-23 04:01:52 +06:00
{
2016-01-06 18:08:14 +01:00
cache . InsertCacheItem ( cacheKey , ( ) = > getCacheItem ( ) , timeout , false , priority , null , cacheDependency ) ;
2013-03-23 04:01:52 +06:00
}
2016-01-06 18:08:14 +01:00
throw new InvalidOperationException ( "Cannot use this obsoleted overload when the current provider is not of type " + typeof ( HttpRuntimeCacheProvider ) ) ;
2013-05-13 19:31:27 -10: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="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>
2013-08-09 11:16:10 +10:00
[Obsolete("Do not use this method, we no longer support the caching overloads with references to CacheDependency, use the overloads specifying a file collection instead")]
2013-05-13 19:31:27 -10:00
public void InsertCacheItem < T > ( string cacheKey ,
CacheItemPriority priority ,
CacheItemRemovedCallback refreshAction ,
CacheDependency cacheDependency ,
TimeSpan ? timeout ,
Func < T > getCacheItem )
{
2016-02-04 11:01:54 +01:00
var cache = GetHttpRuntimeCacheProvider ( RuntimeCache ) ;
2016-01-06 18:08:14 +01:00
if ( cache ! = null )
2013-03-23 04:01:52 +06:00
{
2016-01-06 18:08:14 +01:00
cache . InsertCacheItem ( cacheKey , ( ) = > getCacheItem ( ) , timeout , false , priority , refreshAction , cacheDependency ) ;
2013-03-23 04:01:52 +06:00
}
2016-01-06 18:08:14 +01:00
throw new InvalidOperationException ( "Cannot use this obsoleted overload when the current provider is not of type " + typeof ( HttpRuntimeCacheProvider ) ) ;
2013-05-13 19:31:27 -10:00
}
#endregion
2013-03-12 22:58:21 +04:00
2016-02-04 11:01:54 +01:00
private HttpRuntimeCacheProvider GetHttpRuntimeCacheProvider ( IRuntimeCacheProvider runtimeCache )
{
HttpRuntimeCacheProvider cache ;
var wrapper = RuntimeCache as IRuntimeCacheProviderWrapper ;
if ( wrapper ! = null )
{
cache = wrapper . InnerProvider as HttpRuntimeCacheProvider ;
}
else
{
cache = RuntimeCache as HttpRuntimeCacheProvider ;
}
return cache ;
}
}
2012-10-31 11:36:22 +06:00
}