Oracle Coherence for C++ API
Release 3.6.1.0
E18813-01

- Main Page
- Namespaces
- Classes
- Files

- Alphabetical List
- Class List
- Class Hierarchy
- Class Members

# CacheMap Class Reference

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

Inherits Map.

Inherited by 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.

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, and ConverterCollections::ConverterCacheMap.

The documentation for this class was generated from the following file:

- coherence/net/cache/CacheMap.hpp

Copyright © 2000, 2010, Oracle and/or its affiliates. All rights reserved.