Class CachingProvider
CachingProvider provides basic component of cache system, by default it will use HttpRuntime.Cache.
Namespace: DotNetNuke.Services.Cache
Assembly: DotNetNuke.dll
Syntax
public abstract class CachingProvider : object
Remarks
Using cache will speed up the application to a great degree, we recommend to use cache for whole modules, but sometimes cache also make confuse for user, if we didn't take care of how to make cache expired when needed, such as if a data has already been deleted but the cache aren't clear, it will cause un expected errors. so you should choose a correct performance setting type when you trying to cache some stuff, and always remember update cache immediately after the data changed.
Examples
public static void ClearCache(string cachePrefix)
{
CachingProvider.Instance().Clear("Prefix", GetDnnCacheKey(cachePrefix));
}
Properties
| Improve this Doc View SourceCache
Gets the default cache provider.
Declaration
protected static System.Web.Caching.Cache Cache { get; }
Property Value
| Type | Description |
|---|---|
| System.Web.Caching.Cache | HttpRuntime.Cache. |
Remarks
Using cache will speed up the application to a great degree, we recommend to use cache for whole modules, but sometimes cache also make confuse for user, if we didn't take care of how to make cache expired when needed, such as if a data has already been deleted but the cache aren't clear, it will cause un expected errors. so you should choose a correct performance setting type when you trying to cache some stuff, and always remember update cache immediately after the data changed.
CacheExpirationDisable
Gets a value indicating whether whether current caching provider disabled to expire cache.
Declaration
protected static bool CacheExpirationDisable { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
Remarks
This setting shouldn't affect current server, cache should always expire in current server even this setting set to True.
Methods
| Improve this Doc View SourceCleanCacheKey(String)
Cleans the cache key by remove cache key prefix.
Declaration
public static string CleanCacheKey(string cacheKey)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | cacheKey | The cache key. |
Returns
| Type | Description |
|---|---|
| System.String | cache key without prefix. |
Remarks
Using cache will speed up the application to a great degree, we recommend to use cache for whole modules, but sometimes cache also make confuse for user, if we didn't take care of how to make cache expired when needed, such as if a data has already been deleted but the cache aren't clear, it will cause un expected errors. so you should choose a correct performance setting type when you trying to cache some stuff, and always remember update cache immediately after the data changed.
Clear(String, String)
Clears the specified type.
Declaration
public virtual void Clear(string type, string data)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | type | The type. |
| System.String | data | The data. |
Remarks
Using cache will speed up the application to a great degree, we recommend to use cache for whole modules, but sometimes cache also make confuse for user, if we didn't take care of how to make cache expired when needed, such as if a data has already been deleted but the cache aren't clear, it will cause un expected errors. so you should choose a correct performance setting type when you trying to cache some stuff, and always remember update cache immediately after the data changed.
ClearCacheInternal(String, String, Boolean)
Clears the cache internal.
Declaration
protected void ClearCacheInternal(string cacheType, string data, bool clearRuntime)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | cacheType | Type of the cache. |
| System.String | data | The data. |
| System.Boolean | clearRuntime | if set to |
Remarks
Using cache will speed up the application to a great degree, we recommend to use cache for whole modules, but sometimes cache also make confuse for user, if we didn't take care of how to make cache expired when needed, such as if a data has already been deleted but the cache aren't clear, it will cause un expected errors. so you should choose a correct performance setting type when you trying to cache some stuff, and always remember update cache immediately after the data changed.
GetCacheKey(String)
Gets the cache key with key prefix.
Declaration
public static string GetCacheKey(string cacheKey)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | cacheKey | The cache key. |
Returns
| Type | Description |
|---|---|
| System.String | CachePrefix + CacheKey. |
Remarks
Using cache will speed up the application to a great degree, we recommend to use cache for whole modules, but sometimes cache also make confuse for user, if we didn't take care of how to make cache expired when needed, such as if a data has already been deleted but the cache aren't clear, it will cause un expected errors. so you should choose a correct performance setting type when you trying to cache some stuff, and always remember update cache immediately after the data changed.
GetEnumerator()
CachingProvider provides basic component of cache system, by default it will use HttpRuntime.Cache.
Declaration
public virtual IDictionaryEnumerator GetEnumerator()
Returns
| Type | Description |
|---|---|
| IDictionaryEnumerator |
Remarks
Using cache will speed up the application to a great degree, we recommend to use cache for whole modules, but sometimes cache also make confuse for user, if we didn't take care of how to make cache expired when needed, such as if a data has already been deleted but the cache aren't clear, it will cause un expected errors. so you should choose a correct performance setting type when you trying to cache some stuff, and always remember update cache immediately after the data changed.
Examples
public static void ClearCache(string cachePrefix)
{
CachingProvider.Instance().Clear("Prefix", GetDnnCacheKey(cachePrefix));
}
|
Improve this Doc
View Source
GetItem(String)
Gets the item.
Declaration
public virtual object GetItem(string cacheKey)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | cacheKey | The cache key. |
Returns
| Type | Description |
|---|---|
| System.Object | cache content. |
Remarks
Using cache will speed up the application to a great degree, we recommend to use cache for whole modules, but sometimes cache also make confuse for user, if we didn't take care of how to make cache expired when needed, such as if a data has already been deleted but the cache aren't clear, it will cause un expected errors. so you should choose a correct performance setting type when you trying to cache some stuff, and always remember update cache immediately after the data changed.
Insert(String, Object, DNNCacheDependency, DateTime, TimeSpan, CacheItemPriority, CacheItemRemovedCallback)
Inserts the specified cache key.
Declaration
public virtual void Insert(string cacheKey, object itemToCache, DNNCacheDependency dependency, DateTime absoluteExpiration, TimeSpan slidingExpiration, CacheItemPriority priority, CacheItemRemovedCallback onRemoveCallback)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | cacheKey | The cache key. |
| System.Object | itemToCache | The value. |
| DNNCacheDependency | dependency | The dependency. |
| DateTime | absoluteExpiration | The absolute expiration. |
| TimeSpan | slidingExpiration | The sliding expiration. |
| CacheItemPriority | priority | The priority. |
| CacheItemRemovedCallback | onRemoveCallback | The on remove callback. |
Remarks
Using cache will speed up the application to a great degree, we recommend to use cache for whole modules, but sometimes cache also make confuse for user, if we didn't take care of how to make cache expired when needed, such as if a data has already been deleted but the cache aren't clear, it will cause un expected errors. so you should choose a correct performance setting type when you trying to cache some stuff, and always remember update cache immediately after the data changed.
Insert(String, Object, DNNCacheDependency, DateTime, TimeSpan)
Inserts the specified cache key.
Declaration
public virtual void Insert(string cacheKey, object itemToCache, DNNCacheDependency dependency, DateTime absoluteExpiration, TimeSpan slidingExpiration)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | cacheKey | The cache key. |
| System.Object | itemToCache | The object. |
| DNNCacheDependency | dependency | The dependency. |
| DateTime | absoluteExpiration | The absolute expiration. |
| TimeSpan | slidingExpiration | The sliding expiration. |
Remarks
Using cache will speed up the application to a great degree, we recommend to use cache for whole modules, but sometimes cache also make confuse for user, if we didn't take care of how to make cache expired when needed, such as if a data has already been deleted but the cache aren't clear, it will cause un expected errors. so you should choose a correct performance setting type when you trying to cache some stuff, and always remember update cache immediately after the data changed.
Insert(String, Object, DNNCacheDependency)
Inserts the specified cache key.
Declaration
public virtual void Insert(string cacheKey, object itemToCache, DNNCacheDependency dependency)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | cacheKey | The cache key. |
| System.Object | itemToCache | The object. |
| DNNCacheDependency | dependency | The dependency. |
Remarks
Using cache will speed up the application to a great degree, we recommend to use cache for whole modules, but sometimes cache also make confuse for user, if we didn't take care of how to make cache expired when needed, such as if a data has already been deleted but the cache aren't clear, it will cause un expected errors. so you should choose a correct performance setting type when you trying to cache some stuff, and always remember update cache immediately after the data changed.
Insert(String, Object)
Inserts the specified cache key.
Declaration
public virtual void Insert(string cacheKey, object itemToCache)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | cacheKey | The cache key. |
| System.Object | itemToCache | The object. |
Remarks
Using cache will speed up the application to a great degree, we recommend to use cache for whole modules, but sometimes cache also make confuse for user, if we didn't take care of how to make cache expired when needed, such as if a data has already been deleted but the cache aren't clear, it will cause un expected errors. so you should choose a correct performance setting type when you trying to cache some stuff, and always remember update cache immediately after the data changed.
Instance()
Gets the instance of caching provider.
Declaration
public static CachingProvider Instance()
Returns
| Type | Description |
|---|---|
| CachingProvider | The CachingProvider instance defined in |
Remarks
Using cache will speed up the application to a great degree, we recommend to use cache for whole modules, but sometimes cache also make confuse for user, if we didn't take care of how to make cache expired when needed, such as if a data has already been deleted but the cache aren't clear, it will cause un expected errors. so you should choose a correct performance setting type when you trying to cache some stuff, and always remember update cache immediately after the data changed.
IsWebFarm()
Determines whether is web farm.
Declaration
public virtual bool IsWebFarm()
Returns
| Type | Description |
|---|---|
| System.Boolean |
|
Remarks
Using cache will speed up the application to a great degree, we recommend to use cache for whole modules, but sometimes cache also make confuse for user, if we didn't take care of how to make cache expired when needed, such as if a data has already been deleted but the cache aren't clear, it will cause un expected errors. so you should choose a correct performance setting type when you trying to cache some stuff, and always remember update cache immediately after the data changed.
PurgeCache()
Purges the cache.
Declaration
public virtual string PurgeCache()
Returns
| Type | Description |
|---|---|
| System.String | A message indicating the results of the cache purge. |
Remarks
Using cache will speed up the application to a great degree, we recommend to use cache for whole modules, but sometimes cache also make confuse for user, if we didn't take care of how to make cache expired when needed, such as if a data has already been deleted but the cache aren't clear, it will cause un expected errors. so you should choose a correct performance setting type when you trying to cache some stuff, and always remember update cache immediately after the data changed.
Remove(String)
Removes the specified cache key.
Declaration
public virtual void Remove(string cacheKey)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | cacheKey | The cache key. |
Remarks
Using cache will speed up the application to a great degree, we recommend to use cache for whole modules, but sometimes cache also make confuse for user, if we didn't take care of how to make cache expired when needed, such as if a data has already been deleted but the cache aren't clear, it will cause un expected errors. so you should choose a correct performance setting type when you trying to cache some stuff, and always remember update cache immediately after the data changed.
RemoveInternal(String)
Removes value from the cache.
Declaration
protected void RemoveInternal(string cacheKey)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | cacheKey | The cache key. |
Remarks
Using cache will speed up the application to a great degree, we recommend to use cache for whole modules, but sometimes cache also make confuse for user, if we didn't take care of how to make cache expired when needed, such as if a data has already been deleted but the cache aren't clear, it will cause un expected errors. so you should choose a correct performance setting type when you trying to cache some stuff, and always remember update cache immediately after the data changed.