• Share
    • Twitter
    • LinkedIn
    • Facebook
    • Email
  • Feedback
  • Improve this Doc

Class CachingProvider

CachingProvider provides basic component of cache system, by default it will use HttpRuntime.Cache.

Inheritance
System.Object
CachingProvider
FBCachingProvider
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 Source

Cache

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.

| Improve this Doc View Source

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 Source

CleanCacheKey(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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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 true clear runtime 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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

Instance()

Gets the instance of caching provider.

Declaration
public static CachingProvider Instance()
Returns
Type Description
CachingProvider

The CachingProvider instance defined in web.config.

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.

| Improve this Doc View Source

IsWebFarm()

Determines whether is web farm.

Declaration
public virtual bool IsWebFarm()
Returns
Type Description
System.Boolean

true if is web farm; otherwise, false.

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

Extension Methods

JsonExtensionsWeb.ToJson(Object)
  • View Source
Back to top by the community, for the community... #DNNCMS