Interface ICache
An ICache is a dictionary that supports caching.
Inherited Members
Namespace: Tangosol.Net.Cache
Assembly: Coherence.dll
Syntax
public interface ICache : IDictionary, ICollection, IEnumerable
Properties
Entries
Gets a collection of ICacheEntry instances within the cache.
Declaration
ICollection Entries { get; }
Property Value
Type | Description |
---|---|
ICollection |
Methods
GetAll(ICollection)
Get the values for all the specified keys, if they are in the cache.
Declaration
IDictionary GetAll(ICollection keys)
Parameters
Type | Name | Description |
---|---|---|
ICollection | keys | A collection of keys that may be in the named cache. |
Returns
Type | Description |
---|---|
IDictionary | A dictionary of keys to values for the specified keys passed in
|
Remarks
For each key that is in the cache, that key and its corresponding value will be placed in the dictionary that is returned by this method. The absence of a key in the returned dictionary indicates that it was not in the cache, which may imply (for caches that can load behind the scenes) that the requested data could not be loaded.
The result of this method is defined to be semantically the same as the following implementation, without regards to threading issues:
IDictionary dict = new AnyDictionary(); // could be a Hashtable (but does not have to) foreach (object key in colKeys) { object value = this[key]; if (value != null || Contains(key)) { dict[key] = value; } } return dict;
GetEnumerator()
Returns an ICacheEnumerator object for the ICache instance.
Declaration
ICacheEnumerator GetEnumerator()
Returns
Type | Description |
---|---|
ICacheEnumerator | An ICacheEnumerator object for the ICache instance. |
Insert(object, object)
Associates the specified value with the specified key in this cache.
Declaration
object Insert(object key, object value)
Parameters
Type | Name | Description |
---|---|---|
object | key | Key with which the specified value is to be associated. |
object | value | Value to be associated with the specified key. |
Returns
Type | Description |
---|---|
object | Previous value associated with specified key, or |
Remarks
If the cache previously contained a mapping for this key, the old value is replaced.
Invoking this method is equivalent to the following call:
Insert(key, value, CacheExpiration.Default);
Insert(object, object, long)
Associates the specified value with the specified key in this cache.
Declaration
object Insert(object key, object value, long millis)
Parameters
Type | Name | Description |
---|---|---|
object | key | Key with which the specified value is to be associated. |
object | value | Value to be associated with the specified key. |
long | millis | The number of milliseconds until the cache entry will expire, also referred to as the entry's "time to live"; pass DEFAULT to use the cache's default time-to-live setting; pass NEVER to indicate that the cache entry should never expire; this milliseconds value is not a date/time value, but the amount of time object will be kept in the cache. |
Returns
Type | Description |
---|---|
object | Previous value associated with specified key, or |
Remarks
If the cache previously contained a mapping for this key, the old value is replaced.
This variation of the Insert(object, object) method allows the caller to specify an expiry (or "time to live") for the cache entry.Exceptions
Type | Condition |
---|---|
NotSupportedException | If the requested expiry is a positive value and the implementation does not support expiry of cache entries. |
InsertAll(IDictionary)
Copies all of the mappings from the specified dictionary to this cache (optional operation).
Declaration
void InsertAll(IDictionary dictionary)
Parameters
Type | Name | Description |
---|---|---|
IDictionary | dictionary | Mappings to be stored in this cache. |
Remarks
These mappings will replace any mappings that this cache had for any of the keys currently in the specified dictionary.
Exceptions
Type | Condition |
---|---|
InvalidCastException | If the class of a key or value in the specified dictionary prevents it from being stored in this cache. |
InvalidOperationException | If the lock could not be succesfully obtained for some key. |
NullReferenceException | This cache does not permit |