November Happy Hour will be moved to Thursday December 5th.

Interface IObjectInstanceCache

An interface for local, fast caching of object instances.

Namespace: EPiServer.Framework.Cache
Assembly: EPiServer.Framework.dll
Version: 9.12.2
Syntax
public interface IObjectInstanceCache
Remarks

One assumption is that the objects don't need to be serializable - they will be live object instances.

Another assumption is that the items in the cache may be purged at any point-in-time. When you set expiration time the system will only guarantee that the cached item will not be available after the expiration time, but it may be removed before that time depending on the underlying cache implementation.

Methods

Clear()

Removes all entries from the cache.

Declaration
void Clear()

Get(String)

Gets the specified object.

Declaration
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
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
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
void Remove(string key)
Parameters
Type Name Description
System.String key

The key.

Extension Methods