#include <coherence/net/cache/WrapperNamedCache.hpp>
Inherits Object, and NamedCache.
Inherited by BundlingNamedCache.
Public Types | |||||||||||||
typedef spec::Handle | Handle | ||||||||||||
WrapperNamedCache Handle definition. | |||||||||||||
typedef spec::View | View | ||||||||||||
WrapperNamedCache View definition. | |||||||||||||
typedef spec::Holder | Holder | ||||||||||||
WrapperNamedCache Holder definition. | |||||||||||||
Public Member Functions | |||||||||||||
virtual size32_t | size () const | ||||||||||||
Return the number of key-value mappings in this map.
| |||||||||||||
virtual bool | isEmpty () const | ||||||||||||
Return true if this map contains no key-value mappings.
| |||||||||||||
virtual bool | containsKey (Object::View vKey) const | ||||||||||||
Return true if this map contains a mapping for the specified key.
| |||||||||||||
virtual bool | containsValue (Object::View vValue) const | ||||||||||||
Return true if this map maps one or more keys to the specified value.
This operation will probably require time linear in the map size for most implementations of the
| |||||||||||||
virtual Object::Holder | get (Object::View vKey) const | ||||||||||||
Return the value to which this map maps the specified key.
Return
| |||||||||||||
virtual Object::Holder | get (Object::View vKey) | ||||||||||||
Return the value to which this map maps the specified key.
Return
| |||||||||||||
virtual Object::Holder | put (Object::View vKey, Object::Holder ohValue) | ||||||||||||
Associate the specified value with the specified key in this map. If the map previously contained a mapping for this key, the old value is replaced by the specified value.
| |||||||||||||
virtual Object::Holder | remove (Object::View vKey) | ||||||||||||
Remove the mapping for this key from this map if it is present.
Return the value to which the map previously associated the key, or
| |||||||||||||
virtual void | putAll (Map::View vMap) | ||||||||||||
virtual void | clear () | ||||||||||||
Remove all mappings from this map.
| |||||||||||||
virtual Set::View | keySet () const | ||||||||||||
Return a set of the keys contained in this map. The set is backed by the map, so changes to the map are reflected in the set. If the map is modified while an iteration over the set is in progress, the results of the iteration are undefined.
| |||||||||||||
virtual Set::Handle | keySet () | ||||||||||||
Return a set of the keys contained in this map. The set is backed by the map, so changes to one are reflected in the other. If the map is modified while an iteration over the set is in progress, the results of the iteration are undefined.
| |||||||||||||
virtual Collection::View | values () const | ||||||||||||
Return a collection of the values contained in this map. The collection is backed by the map, so changes to the map are reflected in the set. If the map is modified while an iteration over the collection is in progress, the results of the iteration are undefined.
| |||||||||||||
virtual Collection::Handle | values () | ||||||||||||
Return a collection of the values contained in this map. The collection is backed by the map, so changes to one are reflected in the other. If the map is modified while an iteration over the collection is in progress, the results of the iteration are undefined.
| |||||||||||||
virtual Set::View | entrySet () const | ||||||||||||
Return a set of the mappings contained in this map. Each element in the returned set is a Map::Entry::View. The set is backed by the map, so changes to the map are reflected in the set. If the map is modified while an iteration over the set is in progress, the results of the iteration are undefined.
| |||||||||||||
virtual Set::Handle | entrySet () | ||||||||||||
Return a set of the mappings contained in this map. Each element in the returned set is a Map::Entry::Handle. The set is backed by the map, so changes to one are reflected in the other. If the map is modified while an iteration over the set is in progress, the results of the iteration are undefined.
| |||||||||||||
virtual Map::View | getAll (Collection::View vKeys) const | ||||||||||||
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;
| |||||||||||||
virtual Object::Holder | put (Object::View vKey, Object::Holder ohValue, int64_t cMillis) | ||||||||||||
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.
| |||||||||||||
virtual void | release () | ||||||||||||
Release local resources associated with this instance of NamedCache. Releasing a cache makes it no longer usable, but does not affect the cache itself. In other words, all other references to the cache will still be valid, and the cache data is not affected by releasing the reference. Any attempt to use this reference afterward will result in an exception. Caches should be released by the same mechanism in which they were obtained. For example:
| |||||||||||||
virtual void | destroy () | ||||||||||||
Release and destroy this instance of NamedCache. Warning: This method is used to completely destroy the specified cache across the cluster. All references in the entire cluster to this cache will be invalidated, the cached data will be cleared, and all resources will be released. Caches should be destroyed by the same mechanism in which they were obtained. For example:
| |||||||||||||
virtual void | truncate () | ||||||||||||
Removes all mappings from this map. Note: the removal of entries caused by this truncate operation will not be observable. This includes any registered listeners, triggers, or interceptors. However, a CacheLifecycleEvent is raised to notify subscribers of the execution of this operation.
| |||||||||||||
virtual String::View | getCacheName () const | ||||||||||||
Return the cache name.
| |||||||||||||
virtual bool | isActive () const | ||||||||||||
Specifies whether or not the NamedCache is active.
| |||||||||||||
virtual NamedCache::CacheServiceHandle | getCacheService () | ||||||||||||
Return the CacheService that this NamedCache is a part of.
| |||||||||||||
virtual NamedCache::CacheServiceView | getCacheService () const | ||||||||||||
Return the CacheService that this NamedCache is a part of.
| |||||||||||||
virtual bool | lock (Object::View vKey, int64_t cWait) const | ||||||||||||
Attempt to lock the specified item within the specified period of time. The item doesn't have to exist to be locked. While the item is locked there is known to be a lock holder which has an exclusive right to modify (calling put and remove methods) that item. Lock holder is an abstract concept that depends on the ConcurrentMap implementation. For example, holder could be a process or a thread (or both). Locking strategy may vary for concrete implementations as well. Lock could have an expiration time (this lock is sometimes called a "lease") or be held indefinitely (until the lock holder terminates). Some implementations may allow the entire map to be locked. If the map is locked in such a way, then only a lock holder is allowed to perform any of the "put" or "remove" operations. Pass the special constant getLockAll() as the vKey parameter to indicate the map lock.
| |||||||||||||
virtual bool | lock (Object::View vKey) const | ||||||||||||
Attempt to lock the specified item and return immediately.
This method behaves exactly as if it simply performs the call
| |||||||||||||
virtual bool | unlock (Object::View vKey) const | ||||||||||||
Unlock the specified item. The item doesn't have to exist to be unlocked. If the item is currently locked, only the holder of the lock could successfully unlock it.
| |||||||||||||
virtual Object::Holder | invoke (Object::View vKey, EntryProcessor::Handle hAgent) | ||||||||||||
virtual Map::View | invokeAll (Collection::View vCollKeys, EntryProcessor::Handle hAgent) | ||||||||||||
virtual Map::View | invokeAll (Filter::View vFilter, EntryProcessor::Handle hAgent) | ||||||||||||
virtual Object::Holder | aggregate (Collection::View vCollKeys, EntryAggregator::Handle hAgent) const | ||||||||||||
virtual Object::Holder | aggregate (Filter::View vFilter, EntryAggregator::Handle hAgent) const | ||||||||||||
virtual Set::View | keySet (Filter::View vFilter) const | ||||||||||||
virtual Set::View | entrySet (Filter::View vFilter) const | ||||||||||||
virtual Set::View | entrySet (Filter::View vFilter, Comparator::View vComparator) const | ||||||||||||
virtual void | addIndex (ValueExtractor::View vExtractor, bool fOrdered, Comparator::View vComparator) | ||||||||||||
virtual void | removeIndex (ValueExtractor::View vExtractor) | ||||||||||||
virtual void | addKeyListener (MapListener::Handle hListener, Object::View vKey, bool fLite) | ||||||||||||
virtual void | removeKeyListener (MapListener::Handle hListener, Object::View vKey) | ||||||||||||
virtual void | addMapListener (MapListener::Handle hListener) | ||||||||||||
virtual void | removeMapListener (MapListener::Handle hListener) | ||||||||||||
virtual void | addFilterListener (MapListener::Handle hListener, Filter::View vFilter=NULL, bool fLite=false) | ||||||||||||
virtual void | removeFilterListener (MapListener::Handle hListener, Filter::View vFilter=NULL) | ||||||||||||
virtual TypedHandle < const String > | toString () const | ||||||||||||
Output a human-readable description of this Object to the given stream. Note that when overriding this method the return type must be TypedHandle<const String> rather then String::View. These two types are assignment compatible but not equivalent and declaring the override with String::View will not be a compatible override. coherence::lang::operator<<(std::ostream, Object::View) is defined and will call into the toString method, to output Objects. If a managed String object is desired, the COH_TO_STRING macro can be used to build up a String from streamable contents and is generally how toString() will be implemented.
Object::View vKey = ... Object::View vValue = ... std::cout << vKey << " = " << vValue << std::endl; String::View vs = COH_TO_STRING(vKey << " = " << vValue); The COH_TO_STRING macro is also the most common way to implement the toString method. For example:
virtual TypedHandle<const String> Person::toString() const { return COH_TO_STRING("Name: " << f_sName << " SSN: " << f_nSSN); }
| |||||||||||||
virtual NamedCache::Handle | getNamedCache () | ||||||||||||
Get the actual (wrapped) named cache. | |||||||||||||
virtual NamedCache::View | getNamedCache () const | ||||||||||||
Get the actual (wrapped) named cache. | |||||||||||||
Protected Member Functions | |||||||||||||
WrapperNamedCache (NamedCache::Handle hCache) | |||||||||||||
Create a new WrapperNamedCache. | |||||||||||||
Protected Attributes | |||||||||||||
FinalHandle< NamedCache > | f_hNamedCache | ||||||||||||
Actual (wrapped) NamedCache. |
WrapperNamedCache | ( | NamedCache::Handle | hCache | ) | [protected] |
Create a new WrapperNamedCache.
hCache | the NamedCache that will be wrapped by this WrapperNamedCache |
virtual NamedCache::Handle getNamedCache | ( | ) | [virtual] |
virtual NamedCache::View getNamedCache | ( | ) | const [virtual] |