Class InvocableCacheHelper
Helper methods for IInvocableCache implementations and IFilter related evaluations.
Inherited Members
Namespace: Tangosol.Net.Cache.Support
Assembly: Coherence.dll
Syntax
public abstract class InvocableCacheHelper
Fields
ENTRY_TO_KEY_CONVERTER
Trivial Entry-to-Key converter.
Declaration
public static readonly IConverter ENTRY_TO_KEY_CONVERTER
Field Value
Type | Description |
---|---|
IConverter |
Methods
AddIndex(IValueExtractor, bool, IComparer, IObservableCache, IDictionary)
Add an index to the given dictionary of indexes, keyed by the given extractor. Also add the index as a listener to the given cache.
Declaration
public static void AddIndex(IValueExtractor extractor, bool ordered, IComparer comparator, IObservableCache cache, IDictionary dictIndex)
Parameters
Type | Name | Description |
---|---|---|
IValueExtractor | extractor | The IValueExtractor object that is used to extract an indexable property value from a cache entry. |
bool | ordered | True if the contents of the indexed information should be ordered; false otherwise |
IComparer | comparator | The IComparer object which imposes an ordering on entries in the
indexed cache or |
IObservableCache | cache | The cache that the newly created ICacheIndex will use for initialization and listen to for changes. |
IDictionary | dictIndex | The dictionary of indexes that the newly created ICacheIndex will be added to. |
EnsureListener(ICacheIndex)
Ensure an ICacheListener for the given index. The listener will route the cache events into the corresponding ICacheIndex calls.
Declaration
protected static ICacheListener EnsureListener(ICacheIndex index)
Parameters
Type | Name | Description |
---|---|---|
ICacheIndex | index | The index. |
Returns
Type | Description |
---|---|
ICacheListener | A listener for given index. |
EvaluateEntry(IFilter, object, object)
Check if an entry, expressed as a key and value, passes the filter evaulation.
Declaration
public static bool EvaluateEntry(IFilter filter, object key, object value)
Parameters
Type | Name | Description |
---|---|---|
IFilter | filter | The filter to evaluate against. |
object | key | The key for the entry. |
object | value | The value for the entry. |
Returns
Type | Description |
---|---|
bool | true if the entry passes the filter, false otherwise. |
EvaluateEntry(IFilter, ICacheEntry)
Check if the entry passes the filter evaulation.
Declaration
public static bool EvaluateEntry(IFilter filter, ICacheEntry entry)
Parameters
Type | Name | Description |
---|---|---|
IFilter | filter | The filter to evaluate against. |
ICacheEntry | entry | An ICacheEntry to filter. |
Returns
Type | Description |
---|---|
bool | true if the entry passes the filter, false otherwise. |
EvaluateOriginalEntry(IFilter, CacheEntry)
Check if the entry, in its "original" form, passes the filter evaulation.
Declaration
public static bool EvaluateOriginalEntry(IFilter filter, CacheEntry entry)
Parameters
Type | Name | Description |
---|---|---|
IFilter | filter | The filter to evaluate against. |
CacheEntry | entry | A CacheEntry whose "original" value to evaluate. |
Returns
Type | Description |
---|---|
bool | true iff the entry has an original value and passes the filter, false otherwise. |
ExtractFromEntry(IValueExtractor, ICacheEntry)
Extract a value from the specified entry using the specified extractor.
Declaration
public static object ExtractFromEntry(IValueExtractor extractor, ICacheEntry entry)
Parameters
Type | Name | Description |
---|---|---|
IValueExtractor | extractor | The extractor to use. |
ICacheEntry | entry | The entry to extract from. |
Returns
Type | Description |
---|---|
object | The extracted value. |
ExtractOriginalFromEntry(IValueExtractor, CacheEntry)
Extract a value from the "original value" of the specified entry using the specified extractor.
Declaration
public static object ExtractOriginalFromEntry(IValueExtractor extractor, CacheEntry entry)
Parameters
Type | Name | Description |
---|---|---|
IValueExtractor | extractor | The extractor to use. |
CacheEntry | entry | The entry to extract from. |
Returns
Type | Description |
---|---|
object | The extracted original value. |
InvokeAllLocked(IConcurrentCache, ICollection, IEntryProcessor)
Invoke the passed IEntryProcessor against the entries specified by the passed cache and entries.
Declaration
public static IDictionary InvokeAllLocked(IConcurrentCache cache, ICollection entries, IEntryProcessor agent)
Parameters
Type | Name | Description |
---|---|---|
IConcurrentCache | cache | The IConcurrentCache that the IEntryProcessor works against. |
ICollection | entries | A collection of IInvocableCacheEntry objects to process. |
IEntryProcessor | agent | The IEntryProcessor to use to process the specified keys. |
Returns
Type | Description |
---|---|
IDictionary | An IDictionary containing the results of invoking the IEntryProcessor against each of the specified entry. |
Remarks
The invocation is made thread safe by locking the corresponding keys on the cache. If an attempt to lock all the entries at once fails, they will be processed individually one-by-one.
InvokeLocked(IConcurrentCache, IInvocableCacheEntry, IEntryProcessor)
Invoke the passed IEntryProcessor against the specified IInvocableCacheEntry.
Declaration
public static object InvokeLocked(IConcurrentCache cache, IInvocableCacheEntry entry, IEntryProcessor agent)
Parameters
Type | Name | Description |
---|---|---|
IConcurrentCache | cache | The IConcurrentCache that the IEntryProcessor works against. |
IInvocableCacheEntry | entry | The IInvocableCacheEntry to process; it is not required to exist within the cache. |
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. |
Remarks
The invocation is made thread safe by locking the corresponding key on the cache.
LockAll(IConcurrentCache, ICollection, int)
Attempt to lock all the specified keys within a specified period of time.
Declaration
public static IList LockAll(IConcurrentCache cache, ICollection keys, int waitMillis)
Parameters
Type | Name | Description |
---|---|---|
IConcurrentCache | cache | The IConcurrentCache to use. |
ICollection | keys | A collection of keys to lock. |
int | waitMillis | The number of milliseconds to continue trying to obtain locks; pass zero to return immediately; pass -1 to block the calling thread until the lock could be obtained. |
Returns
Type | Description |
---|---|
IList | An IList containing all the locked keys in the order
opposite to the locking order (LIFO); |
Query(ICache, IDictionary, IFilter, QueryType, bool, IComparer)
Generic implementation of the get methods for the particular IFilter provided.
Declaration
public static object[] Query(ICache cache, IDictionary dictIndex, IFilter filter, InvocableCacheHelper.QueryType queryType, bool sort, IComparer comparer)
Parameters
Type | Name | Description |
---|---|---|
ICache | cache | The ICache to be queried. |
IDictionary | dictIndex | The IDictionary of indexes. |
IFilter | filter | The IFilter object representing the criteria that the entries of this cache should satisfy. |
InvocableCacheHelper.QueryType | queryType | An enum value that defines whether return array should be values, keys or entries. |
bool | sort | If true, sort the result-set before returning. |
IComparer | comparer | The IComparer to use for sorting (optional). |
Returns
Type | Description |
---|---|
object[] | A collection of the keys/values for entries that satisfy the specified criteria. |
Query(ICache, IFilter, QueryType, bool, IComparer)
Generic implementation of the get methods for the particular IFilter provided.
Declaration
public static object[] Query(ICache cache, IFilter filter, InvocableCacheHelper.QueryType queryType, bool sort, IComparer comparer)
Parameters
Type | Name | Description |
---|---|---|
ICache | cache | The ICache to be queried. |
IFilter | filter | The IFilter object representing the criteria that the entries of this cache should satisfy. |
InvocableCacheHelper.QueryType | queryType | An enum value that defines whether return array should be values, keys or entries. |
bool | sort | If true, sort the result-set before returning. |
IComparer | comparer | The IComparer to use for sorting (optional). |
Returns
Type | Description |
---|---|
object[] | A collection of the keys/values for entries that satisfy the specified criteria. |
RemoveIndex(IValueExtractor, IObservableCache, IDictionary)
Remove the index keyed by the given extractor from the given dictionary of indexes. Also, remove the index as a listener from the given cache.
Declaration
public static void RemoveIndex(IValueExtractor extractor, IObservableCache cache, IDictionary dictIndex)
Parameters
Type | Name | Description |
---|---|---|
IValueExtractor | extractor | The IValueExtractor object that is used to extract an indexable object from a value stored in the cache. |
IObservableCache | cache | The resource map associated with the index. |
IDictionary | dictIndex | The dictionary of indexes to remove the ICacheIndex from. |
UnlockAll(IConcurrentCache, ICollection)
Unlock all the specified keys.
Declaration
public static void UnlockAll(IConcurrentCache cache, ICollection keys)
Parameters
Type | Name | Description |
---|---|---|
IConcurrentCache | cache | The IConcurrentCache to use. |
ICollection | keys | A collection of keys to unlock. |