Class CacheEventFilter
IFilter which evaluates the content of a CacheEventArgs object according to the specified criteria.
Inherited Members
Namespace: Tangosol.Util.Filter
Assembly: Coherence.dll
Syntax
public class CacheEventFilter : IFilter, IPortableObject
Remarks
This filter is intended to be used by various IObservableCache listeners that are interested in particular subsets of CacheEvent notifications emitted by the cache.
Usage examples:-
a filter that evaluates to true if an Employee object is
inserted into a cache with a value of IsMarried property set to
true.
new CacheEventFilter(CacheEventMask.Inserted, new EqualsFilter("IsMarried", true));
-
a filter that evaluates to true if any object is removed from
a cache.
new CacheEventFilter(CacheEventMask.Deleted);
-
a filter that evaluates to true if there is an update to an
Employee object where either an old or new value of LastName property
equals to "Smith".
new CacheEventFilter(CacheEventMask.Updated, new EqualsFilter("LastName", "Smith"));
-
a filter that is used to keep a cached keys collection result based
on some cache filter up-to-date.
ICollection keys = new ArrayList(); IFilter filterEvt = new CacheEventFilter(filterCache); ICacheListener listener = new TestListener(); cache.AddCacheListener(listener, filterEvt, true); keys.AddAll(cache.GetKeys(filterCache));
Constructors
CacheEventFilter()
Default constructor.
Declaration
public CacheEventFilter()
CacheEventFilter(CacheEventMask)
Construct a CacheEventFilter that evaluates CacheEventArgs objects based on the specified combination of event types.
Declaration
public CacheEventFilter(CacheEventFilter.CacheEventMask mask)
Parameters
Type | Name | Description |
---|---|---|
CacheEventFilter.CacheEventMask | mask | Any combination of Inserted, Updated and Deleted, UpdatedEntered, UpdatedWithin, UpdatedLeft. |
Remarks
Using this constructor is equivalent to:
new CacheEventFilter(mask, null, CacheEventSyntheticMask.All);
CacheEventFilter(CacheEventMask, CacheEventSyntheticMask)
Construct a CacheEventFilter that evaluates CacheEventArgs objects based on the specified combination of event types.
Declaration
public CacheEventFilter(CacheEventFilter.CacheEventMask mask, CacheEventFilter.CacheEventSyntheticMask maskSynth)
Parameters
Type | Name | Description |
---|---|---|
CacheEventFilter.CacheEventMask | mask | Combination of any of the CacheEventFilter.CacheEventMask values. |
CacheEventFilter.CacheEventSyntheticMask | maskSynth | Combination of any of the CacheEventFilter.CacheEventSyntheticMask |
CacheEventFilter(CacheEventMask, IFilter)
Construct a CacheEventFilter that evaluates CacheEventArgs objects based on the specified combination of event types.
Declaration
public CacheEventFilter(CacheEventFilter.CacheEventMask mask, IFilter filter)
Parameters
Type | Name | Description |
---|---|---|
CacheEventFilter.CacheEventMask | mask | Combination of any of the CacheEventFilter.CacheEventMask values. |
IFilter | filter | Optional filter used for evaluating event values. |
CacheEventFilter(CacheEventMask, IFilter, CacheEventSyntheticMask)
Construct a CacheEventFilter that evaluates CacheEventArgs objects based on the specified combination of event types.
Declaration
public CacheEventFilter(CacheEventFilter.CacheEventMask mask, IFilter filter, CacheEventFilter.CacheEventSyntheticMask maskSynth)
Parameters
Type | Name | Description |
---|---|---|
CacheEventFilter.CacheEventMask | mask | Combination of any of the CacheEventFilter.CacheEventMask values. |
IFilter | filter | Optional filter used for evaluating event values. |
CacheEventFilter.CacheEventSyntheticMask | maskSynth | Combination of any of the CacheEventFilter.CacheEventSyntheticMask |
CacheEventFilter(IFilter)
Construct a CacheEventFilter that evaluates CacheEventArgs objects that would affect the results of a keys collection filter issued by a previous call to Keys.
Declaration
public CacheEventFilter(IFilter filter)
Parameters
Type | Name | Description |
---|---|---|
IFilter | filter | The filter passed previously to a Keys query property. |
Remarks
It is possible to easily implement continuous query functionality.
Using this constructor is equivalent to:new CacheEventFilter(CacheEventMask.Keys, filter, CacheEventSyntheticMask.All);
Fields
m_filter
The event value(s) filter.
Declaration
protected IFilter m_filter
Field Value
Type | Description |
---|---|
IFilter |
m_mask
The event mask.
Declaration
protected CacheEventFilter.CacheEventMask m_mask
Field Value
Type | Description |
---|---|
CacheEventFilter.CacheEventMask |
m_maskSynth
The synthetic mask.
Declaration
protected CacheEventFilter.CacheEventSyntheticMask m_maskSynth
Field Value
Type | Description |
---|---|
CacheEventFilter.CacheEventSyntheticMask |
Properties
EventMask
Obtain the event mask.
Declaration
public virtual CacheEventFilter.CacheEventMask EventMask { get; }
Property Value
Type | Description |
---|---|
CacheEventFilter.CacheEventMask | The event mask. |
Remarks
The mask value is concatenation of any of the CacheEventFilter.CacheEventMask values.
Filter
Obtain the IFilter object used to evaluate the event value(s).
Declaration
public virtual IFilter Filter { get; }
Property Value
Type | Description |
---|---|
IFilter | The filter used to evaluate the event value(s). |
Methods
Equals(object)
Compare the CacheEventFilter with another object to determine equality.
Declaration
public override bool Equals(object o)
Parameters
Type | Name | Description |
---|---|---|
object | o | The CacheEventFilter to compare to. |
Returns
Type | Description |
---|---|
bool | true if this CacheEventFilter and the passed object are equivalent CacheEventFilter objects. |
Overrides
Evaluate(object)
Apply the test to the object.
Declaration
public virtual bool Evaluate(object o)
Parameters
Type | Name | Description |
---|---|---|
object | o | An object to which the test is applied. |
Returns
Type | Description |
---|---|
bool | true if the test passes, false otherwise. |
GetHashCode()
Determine a hash value for the CacheEventFilter object according to the general object.GetHashCode() contract.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
int | An integer hash value for this CacheEventFilter object. |
Overrides
ReadExternal(IPofReader)
Restore the contents of a user type instance by reading its state using the specified IPofReader object.
Declaration
public virtual void ReadExternal(IPofReader reader)
Parameters
Type | Name | Description |
---|---|---|
IPofReader | reader | The IPofReader from which to read the object's state. |
Exceptions
Type | Condition |
---|---|
IOException | If an I/O error occurs. |
ToString()
Return a human-readable description for this CacheEventFilter.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
string | A string description of the CacheEventFilter. |
Overrides
WriteExternal(IPofWriter)
Save the contents of a POF user type instance by writing its state using the specified IPofWriter object.
Declaration
public virtual void WriteExternal(IPofWriter writer)
Parameters
Type | Name | Description |
---|---|---|
IPofWriter | writer | The IPofWriter to which to write the object's state. |
Exceptions
Type | Condition |
---|---|
IOException | If an I/O error occurs. |