#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 with 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 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 from the cache. | |
int | unbind (const KEY &key, VALUE &value) |
int | unbind (CACHE_ENTRY *entry) |
Remove entry from map. | |
Protected Types | |
typedef ACMM< 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. |
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.
|
Base class.
Definition at line 194 of file Hash_Cache_Map_Manager_T.h. |
|
|
The actual value mapped to the key in the map. The 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. |
|
Definition at line 75 of file Hash_Cache_Map_Manager_T.h. |
|
Definition at line 77 of file Hash_Cache_Map_Manager_T.h. |
|
Definition at line 78 of file Hash_Cache_Map_Manager_T.h. |
|
Initialize a with entries.
|
|
Close down a and release dynamically allocated resources. Definition at line 34 of file Hash_Cache_Map_Manager_T.cpp.
00035 { 00036 } |
|
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. References ACE_Hash_Cache_Map_Manager< KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY, ATTRIBUTES >::CACHE_ENTRY.
00042 { 00043 // Insert a entry which has the <key> and the <cache_value> which is 00044 // the combination of the <value> and the attributes of the caching 00045 // strategy. 00046 CACHE_VALUE cache_value (value, 00047 this->caching_strategy_.attributes ()); 00048 00049 int bind_result = this->map_.bind (key, 00050 cache_value, 00051 entry); 00052 00053 if (bind_result != -1) 00054 { 00055 00056 int result = this->caching_strategy_.notify_bind (bind_result, 00057 cache_value.second ()); 00058 00059 if (result == -1) 00060 { 00061 00062 this->map_.unbind (key); 00063 00064 // Unless the notification goes thru the bind operation is 00065 // not complete. 00066 bind_result = -1; 00067 00068 } 00069 } 00070 00071 return bind_result; 00072 } |
|
Associate with . If 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.
00013 {
00014 return ACE_HCMM_BASE::bind (key,
00015 value);
00016 }
|
|
Obtain the entry when the find succeeds.
Definition at line 156 of file Hash_Cache_Map_Manager_T.cpp. References ACE_Hash_Cache_Map_Manager< KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY, ATTRIBUTES >::CACHE_ENTRY, and ACE_Hash_Map_Entry< EXT_ID, INT_ID >::int_id_.
00158 { 00159 // Lookup the key and populate the <value>. 00160 int find_result = this->map_.find (key, 00161 entry); 00162 00163 if (find_result != -1) 00164 { 00165 00166 int result = this->caching_strategy_.notify_find (find_result, 00167 entry->int_id_.second ()); 00168 00169 // Unless the find and notification operations go thru, this 00170 // method is not successful. 00171 if (result == -1) 00172 find_result = -1; 00173 else 00174 find_result = 0; 00175 00176 } 00177 00178 return find_result; 00179 } |
|
Is in the cache?
Definition at line 199 of file Hash_Cache_Map_Manager_T.cpp. References ACE_Hash_Cache_Map_Manager< KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY, ATTRIBUTES >::CACHE_ENTRY, and ACE_Hash_Cache_Map_Manager< KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY, ATTRIBUTES >::find().
00200 { 00201 CACHE_ENTRY *entry = 0; 00202 00203 return this->find (key, 00204 entry); 00205 } |
|
Loopkup entry<key,value> in the cache.
Definition at line 182 of file Hash_Cache_Map_Manager_T.cpp. References ACE_Hash_Cache_Map_Manager< KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY, ATTRIBUTES >::CACHE_ENTRY, and ACE_Hash_Map_Entry< EXT_ID, INT_ID >::int_id_. Referenced by ACE_Hash_Cache_Map_Manager< KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY, ATTRIBUTES >::find().
00184 { 00185 CACHE_ENTRY *entry = 0; 00186 00187 int result = this->find (key, 00188 entry); 00189 00190 if (result != -1) 00191 { 00192 value = entry->int_id_.first (); 00193 } 00194 00195 return result; 00196 } |
|
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. References ACE_Hash_Cache_Map_Manager< KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY, ATTRIBUTES >::CACHE_ENTRY.
00078 { 00079 CACHE_VALUE cache_value (value, 00080 this->caching_strategy_.attributes ()); 00081 00082 int rebind_result = this->map_.rebind (key, 00083 cache_value, 00084 entry); 00085 00086 if (rebind_result != -1) 00087 { 00088 00089 int result = this->caching_strategy_.notify_rebind (rebind_result, 00090 cache_value.second ()); 00091 00092 if (result == -1) 00093 { 00094 00095 // Make sure the unbind operation is done only when the 00096 // notification fails after a bind which is denoted by 00097 // rebind_result = 0 00098 if (rebind_result == 0) 00099 this->map_.unbind (key); 00100 00101 // Unless the notification goes thru the rebind operation is 00102 // not complete. 00103 rebind_result = -1; 00104 00105 } 00106 00107 } 00108 00109 return rebind_result; 00110 } |
|
Reassociate with , storing the old key and value into the "out" parameters and . The function fails if 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 / association is created. Definition at line 37 of file Hash_Cache_Map_Manager_T.inl.
00041 {
00042 return ACE_HCMM_BASE::rebind (key,
00043 value,
00044 old_key,
00045 old_value);
00046 }
|
|
Reassociate with , storing the old value into the "out" parameter . The function fails if 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 / association is created. Definition at line 27 of file Hash_Cache_Map_Manager_T.inl.
00030 {
00031 return ACE_HCMM_BASE::rebind (key,
00032 value,
00033 old_value);
00034 }
|
|
Reassociate the with . If the 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.
00021 {
00022 return ACE_HCMM_BASE::rebind (key,
00023 value);
00024 }
|
|
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. References ACE_Hash_Cache_Map_Manager< KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY, ATTRIBUTES >::CACHE_ENTRY.
00116 { 00117 CACHE_VALUE cache_value (value, 00118 this->caching_strategy_.attributes ()); 00119 00120 int trybind_result = this->map_.trybind (key, 00121 cache_value, 00122 entry); 00123 00124 if (trybind_result != -1) 00125 { 00126 int result = this->caching_strategy_.notify_trybind (trybind_result, 00127 cache_value.second ()); 00128 00129 if (result == -1) 00130 { 00131 00132 // If the entry has got inserted into the map, it is removed 00133 // due to failure. 00134 if (trybind_result == 0) 00135 this->map_.unbind (key); 00136 00137 trybind_result = -1; 00138 00139 } 00140 else 00141 { 00142 00143 // If an attempt is made to bind an existing entry the value 00144 // is overwritten with the value from the map. 00145 if (trybind_result == 1) 00146 value = cache_value.first (); 00147 00148 } 00149 00150 } 00151 00152 return trybind_result; 00153 } |
|
Associate with if and only if is not in the cache. If is already in the cache, then the parameter is overwritten with the existing value in the cache. Returns 0 if a new / 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.
00051 {
00052 return ACE_HCMM_BASE::trybind (key,
00053 value);
00054 }
|
|
Remove entry from map.
Definition at line 208 of file Hash_Cache_Map_Manager_T.cpp. References ACE_Hash_Cache_Map_Manager< KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY, ATTRIBUTES >::CACHE_ENTRY, and ACE_Hash_Map_Entry< EXT_ID, INT_ID >::int_id_.
00209 { 00210 // Remove the entry from the cache. 00211 int unbind_result = this->map_.unbind (entry); 00212 00213 if (unbind_result != -1) 00214 { 00215 00216 int result = this->caching_strategy_.notify_unbind (unbind_result, 00217 entry->int_id_.second ()); 00218 00219 if (result == -1) 00220 unbind_result = -1; 00221 00222 } 00223 00224 return unbind_result; 00225 } |
|
Remove from the cache, and return the associated with . Definition at line 63 of file Hash_Cache_Map_Manager_T.inl.
00065 {
00066 return ACE_HCMM_BASE::unbind (key,
00067 value);
00068 }
|
|
Remove from the cache.
Definition at line 57 of file Hash_Cache_Map_Manager_T.inl. Referenced by ACE_Cached_Connect_Strategy_Ex< SVC_HANDLER,, CACHING_STRATEGY, ATTRIBUTES, MUTEX >::purge_i().
00058 {
00059 return ACE_HCMM_BASE::unbind (key);
00060 }
|