#include <coherence/net/cache/CacheMap.hpp>
Inherits Map.
Inherited by LocalCache [virtual]
, OldCache [virtual]
, NamedCache [virtual]
, and ConverterCollections::ConverterCacheMap [virtual]
.
CacheMaps maintain immutable copies of the cached entries. Thus any non-immutable item supplied to the cache will be cloned. All results from the cache will be accessable only via Views.
Public Types | |
typedef spec::Handle | Handle |
CacheMap Handle definition. | |
typedef spec::View | View |
CacheMap View definition. | |
typedef spec::Holder | Holder |
CacheMap Holder definition. | |
Public Member Functions | |
virtual Map::View | getAll (Collection::View vKeys) const =0 |
Get all the specified keys, if they are in the cache. | |
virtual Object::Holder | put (Object::View vKey, Object::Holder ohValue, int64_t cMillis)=0 |
Associates the specified value with the specified key in this cache. | |
Static Public Attributes | |
static const int64_t | expiry_default |
A special time-to-live value that can be passed to the extended put(Object::Handle, Object::Handle, int64_t) method to indicate that the cache's default expiry should be used. | |
static const int64_t | expiry_never |
A special time-to-live value that can be passed to the extended put(Object::Handle, Object::Handle, int64_t) method to indicate that the cache entry should never expire. |
virtual Map::View getAll | ( | Collection::View | vKeys | ) | const [pure virtual] |
Get all the specified keys, if they are in the cache.
For each key that is in the cache, that key and its corresponding value will be placed in the map that is returned by this method. The absence of a key in the returned map 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:
// could be a HashMap (but does not have to) Map::Handle hMap = SomeMap::create(); for (Iterator::Handle iter = colKeys->iterator(); iter->hasNext();) { Object::View hKey = iter->next(); Object::View hVal = get(hKey); if (hVal || containsKey(hKey)) { hMap->put(hKey, hVal); } } return hMap;
vKeys | a collection of keys that may be in the named cache |
Implemented in ContinuousQueryCache, LocalCache, NearCache, OldCache, and WrapperNamedCache.
virtual Object::Holder put | ( | Object::View | vKey, | |
Object::Holder | ohValue, | |||
int64_t | cMillis | |||
) | [pure virtual] |
Associates the specified value with the specified key in this cache.
If the cache previously contained a mapping for this key, the old value is replaced. This variation of the put(Object::View, Object::View) method allows the caller to specify an expiry (or "time to live") for the cache entry.
vKey | key with which the specified value is to be associated | |
ohValue | value to be associated with the specified key | |
cMillis | the number of milliseconds until the cache entry will expire, also referred to as the entry's "time to live"; pass expiry_default to use the cache's default time-to-live setting; pass expiry_never to indicate that the cache entry should never expire; this milliseconds value is not a date/time value |
coherence::lang::UnsupportedOperationException | if the requested expiry is a positive value and the implementation does not support expiry of cache entries |
Implemented in ContinuousQueryCache, NearCache, OldCache, WrapperNamedCache, and ConverterCollections::ConverterCacheMap.