Defines a abstraction which will purge entries from a map. The map considered is the ACE_Hash_Map_Manager_Ex. More...
#include <Hash_Cache_Map_Manager_T.h>
Public Types | |
typedef ACE_Pair< VALUE, ATTRIBUTES > | CACHE_VALUE |
typedef ACE_Hash_Map_Manager_Ex< KEY, CACHE_VALUE, HASH_KEY, COMPARE_KEYS, ACE_Null_Mutex > | HASH_MAP |
typedef ACE_Hash_Map_Entry < KEY, CACHE_VALUE > | CACHE_ENTRY |
typedef KEY | key_type |
typedef VALUE | mapped_type |
Public Member Functions | |
ACE_Hash_Cache_Map_Manager (CACHING_STRATEGY &caching_s, size_t size=ACE_DEFAULT_MAP_SIZE, ACE_Allocator *alloc=0) | |
Initialize a <Hash_Cache_Map_Manager> with size entries. | |
~ACE_Hash_Cache_Map_Manager (void) | |
int | bind (const KEY &key, const VALUE &value) |
int | bind (const KEY &key, const VALUE &value, CACHE_ENTRY *&entry) |
int | find (const KEY &key, VALUE &value) |
Loopkup entry<key,value> in the cache. | |
int | find (const KEY &key) |
Is key in the cache? | |
int | find (const KEY &key, CACHE_ENTRY *&entry) |
Obtain the entry when the find succeeds. | |
int | rebind (const KEY &key, const VALUE &value) |
int | rebind (const KEY &key, const VALUE &value, VALUE &old_value) |
int | rebind (const KEY &key, const VALUE &value, KEY &old_key, VALUE &old_value) |
int | rebind (const KEY &key, const VALUE &value, CACHE_ENTRY *&entry) |
int | trybind (const KEY &key, VALUE &value) |
int | trybind (const KEY &key, VALUE &value, CACHE_ENTRY *&entry) |
int | unbind (const KEY &key) |
Remove key from the cache. | |
int | unbind (const KEY &key, VALUE &value) |
int | unbind (CACHE_ENTRY *entry) |
Remove entry from map. | |
Protected Types | |
typedef ACE_Cache_Map_Manager < KEY, VALUE, ACE_Hash_Map_Manager_Ex< KEY, ACE_Pair< VALUE, ATTRIBUTES > , HASH_KEY, COMPARE_KEYS, ACE_Null_Mutex > , ACE_Hash_Map_Iterator_Ex < KEY, ACE_Pair< VALUE, ATTRIBUTES >, HASH_KEY, COMPARE_KEYS, ACE_Null_Mutex > , ACE_Hash_Map_Reverse_Iterator_Ex < KEY, ACE_Pair< VALUE, ATTRIBUTES >, HASH_KEY, COMPARE_KEYS, ACE_Null_Mutex > , CACHING_STRATEGY, ATTRIBUTES > | ACE_HCMM_BASE |
Base class. |
Defines a abstraction which will purge entries from a map. The map considered is the ACE_Hash_Map_Manager_Ex.
The Hash_Cache_Map_Manager will manage the map it contains and provide purging on demand from the map. The strategy for caching is decided by the user and provided to the Cache Manager. The Cache Manager acts as a agent and communicates between the Map and the Strategy for purging entries from the map. To tap the optimal methods like find(key,value,entry) present in the ACE_Hash_Map_Manager, Hash_Cache_Map_Manager provides extra functionality on top of the Cache_Map_Manager. No locking mechanism provided since locking at this level isnt efficient. Locking has to be provided by the application.
Definition at line 65 of file Hash_Cache_Map_Manager_T.h.
typedef ACE_Cache_Map_Manager<KEY, VALUE, ACE_Hash_Map_Manager_Ex<KEY, ACE_Pair<VALUE, ATTRIBUTES>, HASH_KEY, COMPARE_KEYS, ACE_Null_Mutex>, ACE_Hash_Map_Iterator_Ex<KEY, ACE_Pair<VALUE, ATTRIBUTES>, HASH_KEY, COMPARE_KEYS, ACE_Null_Mutex>, ACE_Hash_Map_Reverse_Iterator_Ex<KEY, ACE_Pair<VALUE, ATTRIBUTES>, HASH_KEY, COMPARE_KEYS, ACE_Null_Mutex>, CACHING_STRATEGY, ATTRIBUTES> ACE_Hash_Cache_Map_Manager< KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY, ATTRIBUTES >::ACE_HCMM_BASE [protected] |
Base class.
Definition at line 194 of file Hash_Cache_Map_Manager_T.h.
typedef ACE_Hash_Map_Entry<KEY, CACHE_VALUE> ACE_Hash_Cache_Map_Manager< KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY, ATTRIBUTES >::CACHE_ENTRY |
Definition at line 76 of file Hash_Cache_Map_Manager_T.h.
typedef ACE_Pair<VALUE, ATTRIBUTES> ACE_Hash_Cache_Map_Manager< KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY, ATTRIBUTES >::CACHE_VALUE |
The actual value mapped to the key in the map. The <attributes> are used by the strategy and is transparent to the user of this class.
Definition at line 74 of file Hash_Cache_Map_Manager_T.h.
typedef ACE_Hash_Map_Manager_Ex<KEY, CACHE_VALUE, HASH_KEY, COMPARE_KEYS, ACE_Null_Mutex> ACE_Hash_Cache_Map_Manager< KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY, ATTRIBUTES >::HASH_MAP |
Definition at line 75 of file Hash_Cache_Map_Manager_T.h.
typedef KEY ACE_Hash_Cache_Map_Manager< KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY, ATTRIBUTES >::key_type |
Definition at line 77 of file Hash_Cache_Map_Manager_T.h.
typedef VALUE ACE_Hash_Cache_Map_Manager< KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY, ATTRIBUTES >::mapped_type |
Definition at line 78 of file Hash_Cache_Map_Manager_T.h.
ACE_Hash_Cache_Map_Manager< KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY, ATTRIBUTES >::ACE_Hash_Cache_Map_Manager | ( | CACHING_STRATEGY & | caching_s, | |
size_t | size = ACE_DEFAULT_MAP_SIZE , |
|||
ACE_Allocator * | alloc = 0 | |||
) |
Initialize a <Hash_Cache_Map_Manager> with size entries.
Definition at line 24 of file Hash_Cache_Map_Manager_T.cpp.
: ACE_HCMM_BASE (caching_s, size, alloc) { }
ACE_Hash_Cache_Map_Manager< KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY, ATTRIBUTES >::~ACE_Hash_Cache_Map_Manager | ( | void | ) |
Close down a <Cache_Map_Manager> and release dynamically allocated resources.
Definition at line 34 of file Hash_Cache_Map_Manager_T.cpp.
{ }
int ACE_Hash_Cache_Map_Manager< KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY, ATTRIBUTES >::bind | ( | const KEY & | key, | |
const VALUE & | value | |||
) | [inline] |
Associate key with value. If key is already in the MAP then the ENTRY is not changed. Returns 0 if a new entry is bound successfully, returns 1 if an attempt is made to bind an existing entry, and returns -1 if failures occur.
Definition at line 11 of file Hash_Cache_Map_Manager_T.inl.
{ return ACE_HCMM_BASE::bind (key, value); }
int ACE_Hash_Cache_Map_Manager< KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY, ATTRIBUTES >::bind | ( | const KEY & | key, | |
const VALUE & | value, | |||
CACHE_ENTRY *& | entry | |||
) |
Same as a normal bind, except the cache entry is also passed back to the caller. The entry in this case will either be the newly created entry, or the existing one.
Definition at line 39 of file Hash_Cache_Map_Manager_T.cpp.
{ // Insert a entry which has the <key> and the <cache_value> which is // the combination of the <value> and the attributes of the caching // strategy. CACHE_VALUE cache_value (value, this->caching_strategy_.attributes ()); int bind_result = this->map_.bind (key, cache_value, entry); if (bind_result != -1) { int result = this->caching_strategy_.notify_bind (bind_result, cache_value.second ()); if (result == -1) { this->map_.unbind (key); // Unless the notification goes thru the bind operation is // not complete. bind_result = -1; } } return bind_result; }
int ACE_Hash_Cache_Map_Manager< KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY, ATTRIBUTES >::find | ( | const KEY & | key | ) |
Is key in the cache?
Definition at line 199 of file Hash_Cache_Map_Manager_T.cpp.
{ CACHE_ENTRY *entry = 0; return this->find (key, entry); }
int ACE_Hash_Cache_Map_Manager< KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY, ATTRIBUTES >::find | ( | const KEY & | key, | |
CACHE_ENTRY *& | entry | |||
) |
Obtain the entry when the find succeeds.
Definition at line 156 of file Hash_Cache_Map_Manager_T.cpp.
{ // Lookup the key and populate the <value>. int find_result = this->map_.find (key, entry); if (find_result != -1) { int result = this->caching_strategy_.notify_find (find_result, entry->int_id_.second ()); // Unless the find and notification operations go thru, this // method is not successful. if (result == -1) find_result = -1; else find_result = 0; } return find_result; }
int ACE_Hash_Cache_Map_Manager< KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY, ATTRIBUTES >::find | ( | const KEY & | key, | |
VALUE & | value | |||
) |
Loopkup entry<key,value> in the cache.
Definition at line 182 of file Hash_Cache_Map_Manager_T.cpp.
{ CACHE_ENTRY *entry = 0; int result = this->find (key, entry); if (result != -1) { value = entry->int_id_.first (); } return result; }
int ACE_Hash_Cache_Map_Manager< KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY, ATTRIBUTES >::rebind | ( | const KEY & | key, | |
const VALUE & | value, | |||
KEY & | old_key, | |||
VALUE & | old_value | |||
) | [inline] |
Reassociate key with value, storing the old key and value into the "out" parameters old_key and old_value. The function fails if key is not in the cache for caches that do not allow user specified keys. However, for caches that allow user specified keys, if the key is not in the cache, a new key / value association is created.
Definition at line 37 of file Hash_Cache_Map_Manager_T.inl.
{ return ACE_HCMM_BASE::rebind (key, value, old_key, old_value); }
int ACE_Hash_Cache_Map_Manager< KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY, ATTRIBUTES >::rebind | ( | const KEY & | key, | |
const VALUE & | value, | |||
CACHE_ENTRY *& | entry | |||
) |
Same as a normal rebind, except the cache entry is also passed back to the caller. The entry in this case will either be the newly created entry, or the existing one.
Definition at line 75 of file Hash_Cache_Map_Manager_T.cpp.
{ CACHE_VALUE cache_value (value, this->caching_strategy_.attributes ()); int rebind_result = this->map_.rebind (key, cache_value, entry); if (rebind_result != -1) { int result = this->caching_strategy_.notify_rebind (rebind_result, cache_value.second ()); if (result == -1) { // Make sure the unbind operation is done only when the // notification fails after a bind which is denoted by // rebind_result = 0 if (rebind_result == 0) this->map_.unbind (key); // Unless the notification goes thru the rebind operation is // not complete. rebind_result = -1; } } return rebind_result; }
int ACE_Hash_Cache_Map_Manager< KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY, ATTRIBUTES >::rebind | ( | const KEY & | key, | |
const VALUE & | value | |||
) | [inline] |
Reassociate the key with value. If the key already exists in the cache then returns 1, on a new bind returns 0 and returns -1 in case of any failures.
Definition at line 19 of file Hash_Cache_Map_Manager_T.inl.
{ return ACE_HCMM_BASE::rebind (key, value); }
int ACE_Hash_Cache_Map_Manager< KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY, ATTRIBUTES >::rebind | ( | const KEY & | key, | |
const VALUE & | value, | |||
VALUE & | old_value | |||
) | [inline] |
Reassociate key with value, storing the old value into the "out" parameter old_value. The function fails if key is not in the cache for caches that do not allow user specified keys. However, for caches that allow user specified keys, if the key is not in the cache, a new key / value association is created.
Definition at line 27 of file Hash_Cache_Map_Manager_T.inl.
{ return ACE_HCMM_BASE::rebind (key, value, old_value); }
int ACE_Hash_Cache_Map_Manager< KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY, ATTRIBUTES >::trybind | ( | const KEY & | key, | |
VALUE & | value | |||
) | [inline] |
Associate key with value if and only if key is not in the cache. If key is already in the cache, then the value parameter is overwritten with the existing value in the cache. Returns 0 if a new key / value association is created. Returns 1 if an attempt is made to bind an existing entry. This function fails for maps that do not allow user specified keys.
Definition at line 49 of file Hash_Cache_Map_Manager_T.inl.
{ return ACE_HCMM_BASE::trybind (key, value); }
int ACE_Hash_Cache_Map_Manager< KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY, ATTRIBUTES >::trybind | ( | const KEY & | key, | |
VALUE & | value, | |||
CACHE_ENTRY *& | entry | |||
) |
Same as a normal trybind, except the cache entry is also passed back to the caller. The entry in this case will either be the newly created entry, or the existing one.
Definition at line 113 of file Hash_Cache_Map_Manager_T.cpp.
{ CACHE_VALUE cache_value (value, this->caching_strategy_.attributes ()); int trybind_result = this->map_.trybind (key, cache_value, entry); if (trybind_result != -1) { int result = this->caching_strategy_.notify_trybind (trybind_result, cache_value.second ()); if (result == -1) { // If the entry has got inserted into the map, it is removed // due to failure. if (trybind_result == 0) this->map_.unbind (key); trybind_result = -1; } else { // If an attempt is made to bind an existing entry the value // is overwritten with the value from the map. if (trybind_result == 1) value = cache_value.first (); } } return trybind_result; }
int ACE_Hash_Cache_Map_Manager< KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY, ATTRIBUTES >::unbind | ( | const KEY & | key, | |
VALUE & | value | |||
) | [inline] |
Remove key from the cache, and return the value associated with key.
Definition at line 63 of file Hash_Cache_Map_Manager_T.inl.
{ return ACE_HCMM_BASE::unbind (key, value); }
int ACE_Hash_Cache_Map_Manager< KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY, ATTRIBUTES >::unbind | ( | const KEY & | key | ) | [inline] |
Remove key from the cache.
Definition at line 57 of file Hash_Cache_Map_Manager_T.inl.
{ return ACE_HCMM_BASE::unbind (key); }
int ACE_Hash_Cache_Map_Manager< KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY, ATTRIBUTES >::unbind | ( | CACHE_ENTRY * | entry | ) |
Remove entry from map.
Definition at line 208 of file Hash_Cache_Map_Manager_T.cpp.
{ // Remove the entry from the cache. int unbind_result = this->map_.unbind (entry); if (unbind_result != -1) { int result = this->caching_strategy_.notify_unbind (unbind_result, entry->int_id_.second ()); if (result == -1) unbind_result = -1; } return unbind_result; }