Class WeakReferenceCache

Experimental implementation for internal use.

Inheritance
System.Object
WeakReferenceCache
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
public class WeakReferenceCache : IObjectInstanceCache

Constructors

WeakReferenceCache()

Declaration
public WeakReferenceCache()

WeakReferenceCache(Func<DateTime>)

Declaration
public WeakReferenceCache(Func<DateTime> currentTime)
Parameters
Type Name Description
System.Func<System.DateTime> currentTime

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