Class RemoteCacheSynchronization

Default implementation of the synchronized object cache.

Inheritance
System.Object
RemoteCacheSynchronization
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.Events
Assembly: EPiServer.Events.dll
Version: 8.11.0
Syntax
public class RemoteCacheSynchronization : ISynchronizedObjectInstanceCache, IObjectInstanceCache
Remarks

Will wrap an existing IObjectInstanceCache and provide synchronization across multiple computers, using the remote event system.

Constructors

RemoteCacheSynchronization(IObjectInstanceCache)

Initializes a new instance of the RemoteCacheSynchronization class.

Declaration
public RemoteCacheSynchronization(IObjectInstanceCache localCache)
Parameters
Type Name Description
IObjectInstanceCache localCache

The local cache instance to extend with remote synchronization support.

RemoteCacheSynchronization(IObjectInstanceCache, IEventRegistry)

Initializes a new instance of the RemoteCacheSynchronization class.

Declaration
public RemoteCacheSynchronization(IObjectInstanceCache localCache, IEventRegistry eventService)
Parameters
Type Name Description
IObjectInstanceCache localCache

The local cache instance to extend with remote synchronization support.

IEventRegistry eventService

The event service used by this instance to retrieve events.

Fields

LocalCacheManagerRaiserId

The ID of the local cache manager.

Declaration
public static readonly Guid LocalCacheManagerRaiserId
Field Value
Type Description
System.Guid
Remarks

Used by the remote event system to identify who originally created an event and determine appropriate action.

RemoveFromCacheEventId

The ID used to identify cache removals requested by the cache manager.

Declaration
public static readonly Guid RemoveFromCacheEventId
Field Value
Type Description
System.Guid

Properties

ObjectInstanceCache

Gets the object instance cache used by the synchronized cache implementation.

Declaration
public IObjectInstanceCache ObjectInstanceCache { get; }
Property Value
Type Description
IObjectInstanceCache

The object instance cache.

SynchronizationFailedStrategy

Set the strategy for handling missed synchronization information.

Declaration
public FailureRecoveryAction SynchronizationFailedStrategy { get; set; }
Property Value
Type Description
FailureRecoveryAction
Remarks

By default this is set to None, meaning that if we detect a failure in communication with a remote computer, we will simply ignore that error. The potential problem is that we may have stale data in the cache. In most cases stale data is better than aggressively clearing cached data, since clearing the cache can seriously impact a running site.

Methods

Clear()

Removes all entries from the cache.

Declaration
public void Clear()

Get(String)

Gets the specified object.

Declaration
public 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 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 we have no specific policy as to when or why the object should be removed from the cache. I e it may remain in the cache indefinitely.

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

The key.

RemoveLocal(String)

Removes the object instance from the local cache.

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

The key of the cached object.

RemoveRemote(String)

Removes the object instance from remote cache locations.

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

The key of the cached object.

Implements