Oracle® Fusion Middleware C++ API Reference for Oracle Coherence
12c (12.1.3.0.0)

E47891-01

CacheMap Class Reference

#include <coherence/net/cache/CacheMap.hpp>

Inherits Map.

Inherited by LocalCache [virtual], OldCache [virtual], NamedCache [virtual], and ConverterCollections::ConverterCacheMap [virtual].

List of all members.


Detailed Description

A CacheMap is a coherence::util::Map that supports caching.

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.

Author:
mf 2007.11.07

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.

Member Function Documentation

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;

Parameters:
vKeys a collection of keys that may be in the named cache
Returns:
a coherence::util::Map of keys to values for the specified keys passed in vKeys

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.

Parameters:
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
Returns:
previous value associated with specified key, or empty handle if there was no mapping for key. An empty handle return can also indicate that the map previously associated NULL with the specified key, if the implementation supports NULL values
Exceptions:
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.


The documentation for this class was generated from the following file:
Copyright © 2000, 2014, Oracle and/or its affiliates. All rights reserved.