SaaS CMS has officially launched! Learn more now.

Class HttpRuntimeCache

Default implementation of IObjectInstanceCache.

Inheritance
System.Object
HttpRuntimeCache
Inherited Members
System.Object.ToString()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
Namespace: EPiServer.Framework.Cache
Assembly: EPiServer.Framework.dll
Version: 8.11.0
Syntax
[ServiceConfiguration(typeof(IObjectInstanceCache), Lifecycle = ServiceInstanceScope.Singleton)]
public class HttpRuntimeCache : IObjectInstanceCache
Remarks

Uses HttpRuntime.Cache as the underlying cache mechanism.

Constructors

HttpRuntimeCache()

Initializes a new instance of the HttpRuntimeCache class.

Declaration
public HttpRuntimeCache()

Methods

Clear()

Removes all entries from the cache.

Declaration
public virtual void Clear()

Get(String)

Gets the specified object.

Declaration
public virtual object Get(string key)
Parameters
Type Name Description
System.String key

The key.

Returns
Type Description
System.Object

The object associated with the key, if it exists. Otherwise returns null.

Insert(String, Object, CacheEvictionPolicy)

Inserts the value into the cache with the specified key.

Declaration
public virtual void Insert(string key, object value, CacheEvictionPolicy evictionPolicy)
Parameters
Type Name Description
System.String key

The key.

System.Object value

The value to cache.

CacheEvictionPolicy evictionPolicy

The cache eviction policy.

Remarks

The evicitionPolicy can be null. In that case the item may stay in the cache for an undetermined time.

ReadThrough<T>(String, Func<T>, Func<CacheEvictionPolicy>)

Read-through cache handling.

Declaration
public virtual T ReadThrough<T>(string key, Func<T> readValue, Func<CacheEvictionPolicy> evictionPolicy)

    where T : class
Parameters
Type Name Description
System.String key

The key.

System.Func<T> readValue

The function to invoke for retrieving the value if it does not exist in the cache.

System.Func<CacheEvictionPolicy> evictionPolicy

The function to invoke for determining the cache eviction policy in case a new value was retrieved. It can be null in which case a default policy is used.

Returns
Type Description
T

The object associated with the key, if it exists or is read thru the readValue fuction. Otherwise returns null.

Type Parameters
Name Description
T

Type of the value to read.

Remove(String)

Removes the specified object.

Declaration
public virtual void Remove(string key)
Parameters
Type Name Description
System.String key

The key.

Implements