Show / Hide Table of Contents

Interface IInvocableCache

An IInvocableCache is an ICache against which both entry-targeted processing and aggregating operations can be invoked.

Inherited Members
ICache.GetAll(ICollection)
ICache.Insert(object, object)
ICache.Insert(object, object, long)
ICache.InsertAll(IDictionary)
ICache.Entries
ICache.GetEnumerator()
IDictionary.Add(object, object)
IDictionary.Clear()
IDictionary.Contains(object)
IDictionary.Remove(object)
IDictionary.IsFixedSize
IDictionary.IsReadOnly
IDictionary.this[object]
IDictionary.Keys
IDictionary.Values
ICollection.CopyTo(Array, int)
ICollection.Count
ICollection.IsSynchronized
ICollection.SyncRoot
Namespace: Tangosol.Net.Cache
Assembly: Coherence.dll
Syntax
public interface IInvocableCache : ICache, IDictionary, ICollection, IEnumerable
Remarks

While a traditional model for working with a dictionary is to have an operation access and mutate the dictionary directly through its API, the IInvocableCache allows that model of operation to be inverted such that the operations against the cache contents are executed by (and thus within the localized context of) a cache. This is particularly useful in a distributed environment, because it enables the processing to be moved to the location at which the entries-to-be-processed are being managed, thus providing efficiency by localization of processing.

Methods

Aggregate(ICollection, IEntryAggregator)

Perform an aggregating operation against the entries specified by the passed keys.

Declaration
object Aggregate(ICollection keys, IEntryAggregator agent)
Parameters
Type Name Description
ICollection keys

The collection of keys that specify the entries within this cache to aggregate across.

IEntryAggregator agent

The IEntryAggregator that is used to aggregate across the specified entries of this dictionary.

Returns
Type Description
object

The result of the aggregation.

Aggregate(IFilter, IEntryAggregator)

Perform an aggregating operation against the collection of entries that are selected by the given IFilter.

Declaration
object Aggregate(IFilter filter, IEntryAggregator agent)
Parameters
Type Name Description
IFilter filter

an IFilter that is used to select entries within this cache to aggregate across.

IEntryAggregator agent

The IEntryAggregator that is used to aggregate across the selected entries of this dictionary.

Returns
Type Description
object

The result of the aggregation.

Invoke(object, IEntryProcessor)

Invoke the passed IEntryProcessor against the entry specified by the passed key, returning the result of the invocation.

Declaration
object Invoke(object key, IEntryProcessor agent)
Parameters
Type Name Description
object key

The key to process; it is not required to exist within the dictionary.

IEntryProcessor agent

The IEntryProcessor to use to process the specified key.

Returns
Type Description
object

The result of the invocation as returned from the IEntryProcessor.

InvokeAll(ICollection, IEntryProcessor)

Invoke the passed IEntryProcessor against the entries specified by the passed keys, returning the result of the invocation for each.

Declaration
IDictionary InvokeAll(ICollection keys, IEntryProcessor agent)
Parameters
Type Name Description
ICollection keys

The keys to process; these keys are not required to exist within the dictionary.

IEntryProcessor agent

The IEntryProcessor to use to process the specified keys.

Returns
Type Description
IDictionary

A dictionary containing the results of invoking the IEntryProcessor against each of the specified keys.

InvokeAll(IFilter, IEntryProcessor)

Invoke the passed IEntryProcessor against the set of entries that are selected by the given IFilter, returning the result of the invocation for each.

Declaration
IDictionary InvokeAll(IFilter filter, IEntryProcessor agent)
Parameters
Type Name Description
IFilter filter

An IFilter that results in the collection of keys to be processed.

IEntryProcessor agent

The IEntryProcessor to use to process the specified keys.

Returns
Type Description
IDictionary

A dictionary containing the results of invoking the IEntryProcessor against the keys that are selected by the given IFilter.

Remarks

Unless specified otherwise, IInvocableCache implementations will perform this operation in two steps: (1) use the filter to retrieve a matching entry collection; (2) apply the agent to every filtered entry. This algorithm assumes that the agent's processing does not affect the result of the specified filter evaluation, since the filtering and processing could be performed in parallel on different threads.

If this assumption does not hold, the processor logic has to be idempotent, or at least re-evaluate the filter. This could be easily accomplished by wrapping the processor with the ConditionalProcessor.

Extension Methods

InvocableCacheEx.GetOrDefault(IInvocableCache, object, object)
InvocableCacheEx.InsertIfAbsent(IInvocableCache, object, object)
InvocableCacheEx.Remove(IInvocableCache, object, object)
InvocableCacheEx.Replace(IInvocableCache, object, object)
InvocableCacheEx.Replace(IInvocableCache, object, object, object)
In this article
Back to top Copyright © 2000, 2024, Oracle and/or its affiliates.