#include <Cache_Map_Manager_T.h>
Public Types | |
| typedef KEY | key_type |
| typedef VALUE | mapped_type |
| typedef MAP | map_type |
| typedef CACHING_STRATEGY | caching_strategy_type |
| typedef ITERATOR_IMPL | ITERATOR_IMPLEMENTATION |
| typedef REVERSE_ITERATOR_IMPL | REVERSE_ITERATOR_IMPLEMENTATION |
| typedef ACE_Cache_Map_Iterator< KEY, VALUE, ITERATOR_IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES > | ITERATOR |
| typedef ACE_Cache_Map_Reverse_Iterator< KEY, VALUE, REVERSE_ITERATOR_IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES > | REVERSE_ITERATOR |
| typedef ITERATOR | iterator |
| typedef REVERSE_ITERATOR | reverse_iterator |
| typedef ACE_Pair< VALUE, ATTRIBUTES > | CACHE_VALUE |
Public Methods | |
| ACE_Cache_Map_Manager (CACHING_STRATEGY &caching_strategy, size_t size=ACE_DEFAULT_MAP_SIZE, ACE_Allocator *alloc=0) | |
| Initialize a <Cache_Map_Manager> with <caching_strategy> and <size> entries. More... | |
| virtual | ~ACE_Cache_Map_Manager (void) |
| Close down a <Cache_Map_Manager> and release dynamically allocated resources. More... | |
| int | open (size_t length=ACE_DEFAULT_MAP_SIZE, ACE_Allocator *alloc=0) |
| Initialize a cache with size <length>. More... | |
| int | close (void) |
| Close down a cache and release dynamically allocated resources. More... | |
| int | bind (const KEY &key, const VALUE &value) |
| int | find (const KEY &key, VALUE &value) |
| int | find (const KEY &key) |
| 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 | trybind (const KEY &key, VALUE &value) |
| int | unbind (const KEY &key) |
| Remove <key> from the cache. More... | |
| int | unbind (const KEY &key, VALUE &value) |
| Remove <key> from the cache, and return the <value> associated with <key>. More... | |
| int | purge (void) |
| Remove entries from the cache depending upon the strategy. More... | |
| size_t | current_size (void) const |
| Return the current size of the cache. More... | |
| size_t | total_size (void) const |
| Return the total size of the cache. More... | |
| void | dump (void) const |
| Dumps the state of the object. More... | |
| ITERATOR | begin (void) |
| Return forward iterator. More... | |
| ITERATOR | end (void) |
| REVERSE_ITERATOR | rbegin (void) |
| Return reverse iterator. More... | |
| REVERSE_ITERATOR | rend (void) |
| MAP & | map (void) |
| The map managed by the Cache_Map_Manager. More... | |
| CACHING_STRATEGY & | caching_strategy (void) |
| The caching strategy used on the cache. More... | |
Protected Attributes | |
| MAP | map_ |
| The underlying map which needs to be cached. More... | |
| CACHING_STRATEGY & | caching_strategy_ |
| The strategy to be followed for caching entries in the map. More... | |
Private Methods | |
| void | operator= (const ACMM< KEY, VALUE, MAP, ITERATOR_IMPL, REVERSE_ITERATOR_IMPL, CACHING_STRATEGY, ATTRIBUTES > &) |
| ACMM (const ACMM< KEY, VALUE, MAP, ITERATOR_IMPL, REVERSE_ITERATOR_IMPL, CACHING_STRATEGY, ATTRIBUTES > &) | |
Friends | |
| class | ACE_Cache_Map_Iterator< KEY, VALUE, ITERATOR_IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES > |
| class | ACE_Cache_Map_Reverse_Iterator< KEY, VALUE, REVERSE_ITERATOR_IMPLEMENTATION, CACHING_STRATEGY, ATTRIBUTES > |
The <ACE_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. No locking mechanism provided since locking at this level isn't efficient. Locking has to be provided by the application.
Definition at line 71 of file Cache_Map_Manager_T.h.
|
|||||
|
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 108 of file Cache_Map_Manager_T.h. |
|
|||||
|
Definition at line 79 of file Cache_Map_Manager_T.h. |
|
|||||
|
Definition at line 97 of file Cache_Map_Manager_T.h. |
|
|||||
|
Definition at line 91 of file Cache_Map_Manager_T.h. |
|
|||||
|
Definition at line 83 of file Cache_Map_Manager_T.h. |
|
|||||
|
Definition at line 76 of file Cache_Map_Manager_T.h. |
|
|||||
|
Definition at line 78 of file Cache_Map_Manager_T.h. |
|
|||||
|
Definition at line 77 of file Cache_Map_Manager_T.h. |
|
|||||
|
Definition at line 99 of file Cache_Map_Manager_T.h. |
|
|||||
|
Definition at line 93 of file Cache_Map_Manager_T.h. |
|
|||||
|
Definition at line 84 of file Cache_Map_Manager_T.h. |
|
||||||||||||||||||||
|
Initialize a <Cache_Map_Manager> with <caching_strategy> and <size> entries.
Definition at line 40 of file Cache_Map_Manager_T.cpp. References ACE_ERROR, ACE_LIB_TEXT, LM_ERROR, and open.
00043 : caching_strategy_ (caching_s) 00044 { 00045 if (this->open (size, alloc) == -1) 00046 ACE_ERROR ((LM_ERROR, 00047 ACE_LIB_TEXT ("%p\n"), 00048 ACE_LIB_TEXT ("ACE_Cache_Map_Manager::ACE_Cache_Map_Manager"))); 00049 00050 } |
|
||||||||||
|
Close down a <Cache_Map_Manager> and release dynamically allocated resources.
Definition at line 53 of file Cache_Map_Manager_T.cpp. References close.
00054 {
00055 this->close ();
00056 }
|
|
||||||||||
|
|
|
||||||||||
|
Return forward iterator.
Definition at line 50 of file Cache_Map_Manager_T.i. References ITERATOR.
00051 {
00052 return ITERATOR (this->map_.begin ());
00053 }
|
|
||||||||||||||||
|
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 73 of file Cache_Map_Manager_T.cpp. References caching_strategy_, map_, and ACE_Pair::second.
00075 {
00076 // Insert an entry which has the <key> and the <cache_value> which
00077 // is the combination of the <value> and the attributes of the
00078 // caching strategy.
00079 CACHE_VALUE cache_value (value,
00080 this->caching_strategy_.attributes ());
00081
00082 int bind_result = this->map_.bind (key,
00083 cache_value);
00084
00085 if (bind_result != -1)
00086 {
00087
00088 int result = this->caching_strategy_.notify_bind (bind_result,
00089 cache_value.second ());
00090
00091 if (result == -1)
00092 {
00093
00094 this->map_.unbind (key);
00095
00096 // Unless the notification goes thru the bind operation is
00097 // not complete.
00098 bind_result = -1;
00099
00100 }
00101
00102 }
00103
00104 return bind_result;
00105 }
|
|
||||||||||
|
The caching strategy used on the cache.
Definition at line 42 of file Cache_Map_Manager_T.i. References caching_strategy_. Referenced by purge.
00043 {
00044 return this->caching_strategy_;
00045 }
|
|
||||||||||
|
Close down a cache and release dynamically allocated resources.
Definition at line 67 of file Cache_Map_Manager_T.cpp. References map_. Referenced by ~ACE_Cache_Map_Manager.
00068 {
00069 return this->map_.close ();
00070 }
|
|
||||||||||
|
Return the current size of the cache.
Definition at line 24 of file Cache_Map_Manager_T.i. References map_.
00025 {
00026 return this->map_.current_size ();
00027 }
|
|
||||||||||
|
Dumps the state of the object.
Definition at line 411 of file Cache_Map_Manager_T.cpp. References caching_strategy_, and map_.
00412 {
00413 this->map_.dump ();
00414
00415 this->caching_strategy_.dump ();
00416 }
|
|
||||||||||
|
Definition at line 56 of file Cache_Map_Manager_T.i. References ITERATOR.
00057 {
00058 return ITERATOR (this->map_.end ());
00059 }
|
|
||||||||||
|
Lookup entry<key,value> in the cache. If it is not found, returns -1. If the <key> is located in the MAP object, the CACHING_STRATEGY is notified of it via notify_find (int result, ATTRIBUTES &attribute). If notify_find also returns 0 (success), then this function returns 0 (success). Definition at line 323 of file Cache_Map_Manager_T.cpp. References caching_strategy_, map_, and ACE_Pair::second.
00324 {
00325 // Lookup the key and populate the <value>.
00326 CACHE_VALUE cache_value;
00327
00328 int find_result = this->map_.find (key,
00329 cache_value);
00330
00331 if (find_result != -1)
00332 {
00333
00334 int result = this->caching_strategy_.notify_find (find_result,
00335 cache_value.second ());
00336
00337 // Unless the find and notification operations go thru, this
00338 // method is not successful.
00339 if (result == -1)
00340 find_result = -1;
00341 else
00342 {
00343
00344 // Since the <cache_value> has now changed after the
00345 // notification, we need to bind to the map again.
00346 int rebind_result = this->map_.rebind (key,
00347 cache_value);
00348
00349 if (rebind_result == -1)
00350 find_result = -1;
00351
00352 }
00353
00354 }
00355
00356 return find_result;
00357 }
|
|
||||||||||||||||
|
Lookup entry<key,value> in the cache. If it is not found, returns -1. If the <key> is located in the MAP object, the CACHING_STRATEGY is notified of it via notify_find (int result, ATTRIBUTES &attribute). If notify_find also returns 0 (success), then this function returns 0 (success) and sets the cached value in <value>. Definition at line 284 of file Cache_Map_Manager_T.cpp. References caching_strategy_, ACE_Pair::first, map_, and ACE_Pair::second.
00286 {
00287 // Lookup the key and populate the <value>.
00288 CACHE_VALUE cache_value;
00289
00290 int find_result = this->map_.find (key,
00291 cache_value);
00292
00293 if (find_result != -1)
00294 {
00295
00296 int result = this->caching_strategy_.notify_find (find_result,
00297 cache_value.second ());
00298
00299 // Unless the find and notification operations go thru, this
00300 // method is not successful.
00301 if (result == -1)
00302 find_result = -1;
00303 else
00304 {
00305
00306 // Since the <cache_value> has now changed after the
00307 // notification, we need to bind to the map again.
00308 int rebind_result = this->map_.rebind (key,
00309 cache_value);
00310 if (rebind_result == -1)
00311 find_result = -1;
00312 else
00313 value = cache_value.first ();
00314
00315 }
00316
00317 }
00318
00319 return find_result;
00320 }
|
|
||||||||||
|
The map managed by the Cache_Map_Manager.
Definition at line 36 of file Cache_Map_Manager_T.i. References map_.
00037 {
00038 return this->map_;
00039 }
|
|
||||||||||||||||
|
Initialize a cache with size <length>.
Definition at line 59 of file Cache_Map_Manager_T.cpp. References map_. Referenced by ACE_Cache_Map_Manager.
00061 {
00062 return this->map_.open (length,
00063 alloc);
00064 }
|
|
||||||||||
|
|
|
||||||||||
|
Remove entries from the cache depending upon the strategy.
Definition at line 17 of file Cache_Map_Manager_T.i. References caching_strategy.
00018 {
00019 return this->caching_strategy ().caching_utility ().clear_cache (this->map_,
00020 this->caching_strategy ().purge_percent ());
00021 }
|
|
||||||||||
|
Return reverse iterator.
Definition at line 62 of file Cache_Map_Manager_T.i. References REVERSE_ITERATOR.
00063 {
00064 return REVERSE_ITERATOR (this->map_.rbegin ());
00065 }
|
|
||||||||||||||||||||||||
|
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 193 of file Cache_Map_Manager_T.cpp. References caching_strategy_, ACE_Pair::first, map_, and ACE_Pair::second.
00197 {
00198 CACHE_VALUE cache_value (value,
00199 this->caching_strategy_.attributes ());
00200
00201 CACHE_VALUE old_cache_value (old_value,
00202 this->caching_strategy_.attributes ());
00203
00204 int rebind_result = this->map_.rebind (key,
00205 cache_value,
00206 old_key,
00207 old_cache_value);
00208
00209 if (rebind_result != -1)
00210 {
00211
00212 int result = this->caching_strategy_.notify_rebind (rebind_result,
00213 cache_value.second ());
00214
00215 if (result == -1)
00216 {
00217
00218 // Make sure the unbind operation is done only when the
00219 // notification fails after a bind which is denoted by
00220 // rebind_result = 0
00221 if (rebind_result == 0)
00222 this->map_.unbind (key);
00223
00224 // Unless the notification goes thru the rebind operation is
00225 // not complete.
00226 rebind_result = -1;
00227
00228 }
00229 else
00230 {
00231
00232 old_value = old_cache_value.first ();
00233
00234 }
00235
00236 }
00237
00238 return rebind_result;
00239 }
|
|
||||||||||||||||||||
|
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 146 of file Cache_Map_Manager_T.cpp. References caching_strategy_, ACE_Pair::first, map_, and ACE_Pair::second.
00149 {
00150 CACHE_VALUE cache_value (value,
00151 this->caching_strategy_.attributes ());
00152
00153 CACHE_VALUE old_cache_value (old_value,
00154 this->caching_strategy_.attributes ());
00155
00156 int rebind_result = this->map_.rebind (key,
00157 cache_value,
00158 old_cache_value);
00159
00160 if (rebind_result != -1)
00161 {
00162
00163 int result = this->caching_strategy_.notify_rebind (rebind_result,
00164 cache_value.second ());
00165
00166 if (result == -1)
00167 {
00168
00169 // Make sure the unbind operation is done only when the
00170 // notification fails after a bind which is denoted by
00171 // rebind_result = 0
00172 if (rebind_result == 0)
00173 this->map_.unbind (key);
00174
00175 // Unless the notification goes thru the rebind operation is
00176 // not complete.
00177 rebind_result = -1;
00178
00179 }
00180 else
00181 {
00182
00183 old_value = old_cache_value.first ();
00184
00185 }
00186
00187 }
00188
00189 return rebind_result;
00190 }
|
|
||||||||||||||||
|
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 109 of file Cache_Map_Manager_T.cpp. References caching_strategy_, map_, and ACE_Pair::second.
00111 {
00112 CACHE_VALUE cache_value (value,
00113 this->caching_strategy_.attributes ());
00114
00115 int rebind_result = this->map_.rebind (key,
00116 cache_value);
00117
00118 if (rebind_result != -1)
00119 {
00120
00121 int result = this->caching_strategy_.notify_rebind (rebind_result,
00122 cache_value.second ());
00123
00124 if (result == -1)
00125 {
00126
00127 // Make sure the unbind operation is done only when the
00128 // notification fails after a bind which is denoted by
00129 // rebind_result = 0
00130 if (rebind_result == 0)
00131 this->map_.unbind (key);
00132
00133 // Unless the notification goes thru the rebind operation is
00134 // not complete.
00135 rebind_result = -1;
00136
00137 }
00138
00139 }
00140
00141 return rebind_result;
00142 }
|
|
||||||||||
|
Definition at line 67 of file Cache_Map_Manager_T.i. References REVERSE_ITERATOR.
00068 {
00069 return REVERSE_ITERATOR (this->map_.rend ());
00070 }
|
|
||||||||||
|
Return the total size of the cache.
Definition at line 30 of file Cache_Map_Manager_T.i. References map_.
00031 {
00032 return this->map_.total_size ();
00033 }
|
|
||||||||||||||||
|
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 242 of file Cache_Map_Manager_T.cpp. References caching_strategy_, ACE_Pair::first, map_, and ACE_Pair::second.
00244 {
00245 CACHE_VALUE cache_value (value,
00246 this->caching_strategy_.attributes ());
00247
00248 int trybind_result = this->map_.trybind (key,
00249 cache_value);
00250
00251 if (trybind_result != -1)
00252 {
00253
00254 int result = this->caching_strategy_.notify_trybind (trybind_result,
00255 cache_value.second ());
00256
00257 if (result == -1)
00258 {
00259
00260 // If the entry has got inserted into the map, it is removed
00261 // due to failure.
00262 if (trybind_result == 0)
00263 this->map_.unbind (key);
00264
00265 trybind_result = -1;
00266
00267 }
00268 else
00269 {
00270
00271 // If an attempt is made to bind an existing entry the value
00272 // is overwritten with the value from the map.
00273 if (trybind_result == 1)
00274 value = cache_value.first ();
00275
00276 }
00277
00278 }
00279
00280 return trybind_result;
00281 }
|
|
||||||||||||||||
|
Remove <key> from the cache, and return the <value> associated with <key>.
Definition at line 384 of file Cache_Map_Manager_T.cpp. References caching_strategy_, ACE_Pair::first, map_, and ACE_Pair::second.
00386 {
00387 // Remove the entry from the cache.
00388 CACHE_VALUE cache_value;
00389
00390 int unbind_result = this->map_.unbind (key,
00391 cache_value);
00392
00393 if (unbind_result != -1)
00394 {
00395
00396 int result = this->caching_strategy_.notify_unbind (unbind_result,
00397 cache_value.second ());
00398
00399 if (result == -1)
00400 unbind_result = -1;
00401 else
00402 value = cache_value.first ();
00403
00404 }
00405
00406 return unbind_result;
00407 }
|
|
||||||||||
|
Remove <key> from the cache.
Definition at line 361 of file Cache_Map_Manager_T.cpp. References caching_strategy_, map_, and ACE_Pair::second.
00362 {
00363 // Remove the entry from the cache.
00364 CACHE_VALUE cache_value;
00365
00366 int unbind_result = this->map_.unbind (key,
00367 cache_value);
00368
00369 if (unbind_result != -1)
00370 {
00371
00372 int result = this->caching_strategy_.notify_unbind (unbind_result,
00373 cache_value.second ());
00374
00375 if (result == -1)
00376 unbind_result = -1;
00377
00378 }
00379
00380 return unbind_result;
00381 }
|
|
|||||
|
Definition at line 86 of file Cache_Map_Manager_T.h. |
|
|||||
|
Definition at line 87 of file Cache_Map_Manager_T.h. |
|
|||||
|
The strategy to be followed for caching entries in the map.
Definition at line 246 of file Cache_Map_Manager_T.h. Referenced by bind, caching_strategy, dump, find, rebind, trybind, and unbind. |
|
|||||
|
The underlying map which needs to be cached.
Definition at line 243 of file Cache_Map_Manager_T.h. Referenced by bind, close, current_size, dump, find, map, open, rebind, total_size, trybind, and unbind. |
1.2.14 written by Dimitri van Heesch,
© 1997-2002