Interface ICacheTrigger
ICacheTrigger represents a functional agent that allows to validate, reject or modify mutating operations against an underlying cache.
Namespace: Tangosol.Net.Cache
Assembly: Coherence.dll
Syntax
public interface ICacheTrigger
Remarks
The trigger operates on ICacheTriggerEntry object that represents a pending mutation that is about to be committed to the underlying cache. An ICacheTrigger could be registered with any IObservableCache using the CacheTriggerListener class:
INamedCache cache = CacheFactory.GetCache(cacheName);
ICacheTrigger trigger = new MyCustomTrigger();
cache.AddCacheListener(new CacheTriggerListener(trigger));
Note: In a clustered environment, ICacheTrigger registration
process requires triggers to be serializable and providing a non-default implementation of the GetHashCode() and Equals() methods. Failure to do so may result in duplicate registration and a redundant entry processing by equivalent, but "not equal" ICacheTrigger objects.
Methods
Process(ICacheTriggerEntry)
This method is called before the result of a mutating operation represented by the specified entry object is committed into the underlying cache.
Declaration
void Process(ICacheTriggerEntry entry)
Parameters
Type | Name | Description |
---|---|---|
ICacheTriggerEntry | entry | An ICacheTriggerEntry object that represents the pending change to be committed to the cache, as well as the original state of the entry. |
Remarks
An implementation of this method can evaluate the change by analyzing the original and the new value, and can perform any of the following:
- override the requested change by setting Value to a different value;
- undo the pending change by resetting the entry value to the original value obtained from OriginalValue
- remove the entry from the underlying cache by calling Remove(bool)
- reject the pending change by throwing an Exception, which will prevent any changes from being committed, and will result in the exception being thrown from the operation that attempted to modify the cache; or
- do nothing, thus allowing the pending change to be committed to the underlying cache.