#include <Caching_Utility_T.h>
Public Types | |
| typedef ACE_Handler_Cleanup_Strategy< KEY, VALUE, CONTAINER >  | CLEANUP_STRATEGY | 
| typedef ACE_Cleanup_Strategy< KEY, VALUE, CONTAINER >  | CLEANUP_STRATEGY_BASE | 
Public Member Functions | |
| ACE_Handler_Caching_Utility (ACE_Cleanup_Strategy< KEY, VALUE, CONTAINER > *cleanup_strategy=0, int delete_cleanup_strategy=0) | |
| Constructor.   | |
| ~ACE_Handler_Caching_Utility (void) | |
| Destructor.   | |
| int | clear_cache (CONTAINER &container, double purge_percent) | 
Protected Member Functions | |
| void | minimum (CONTAINER &container, KEY *&key_to_remove, VALUE *&value_to_remove) | 
Protected Attributes | |
| CLEANUP_STRATEGY_BASE * | cleanup_strategy_ | 
| int | delete_cleanup_strategy_ | 
| Whether the cleanup_strategy should be destroyed or not.   | |
Private Member Functions | |
| void | operator= (const ACE_Handler_Caching_Utility< KEY, VALUE, CONTAINER, ITERATOR, ATTRIBUTES > &) | 
| ACE_Handler_Caching_Utility (const ACE_Handler_Caching_Utility< KEY, VALUE, CONTAINER, ITERATOR, ATTRIBUTES > &) | |
This class defines the methods commonly used by the different caching strategies. For instance: method which decides and purges the entry from the container.
Definition at line 228 of file Caching_Utility_T.h.
      
  | 
  |||||
| 
 
 Definition at line 232 of file Caching_Utility_T.h.  | 
  
      
  | 
  |||||
| 
 
 Definition at line 233 of file Caching_Utility_T.h.  | 
  
      
  | 
  ||||||||||||||||
| 
 Constructor. 
 Definition at line 364 of file Caching_Utility_T.cpp. References ACE_NEW. 
 00366 : cleanup_strategy_ (cleanup_strategy), 00367 delete_cleanup_strategy_ (delete_cleanup_strategy) 00368 { 00369 if (cleanup_strategy == 0) 00370 { 00371 ACE_NEW (this->cleanup_strategy_, 00372 CLEANUP_STRATEGY); 00373 this->delete_cleanup_strategy_ = 1; 00374 } 00375 }  | 
  
      
  | 
  ||||||||||
| 
 Destructor. 
 Definition at line 378 of file Caching_Utility_T.cpp. 
 00379 {
00380   if (this->delete_cleanup_strategy_)
00381     delete this->cleanup_strategy_;
00382 }
 | 
  
      
  | 
  ||||||||||
| 
 
  | 
  
      
  | 
  ||||||||||||||||
| 
 Purge entries from the . The Cleanup_Strategy will do the actual job of cleanup once the entries to be cleaned up are decided. Definition at line 385 of file Caching_Utility_T.cpp. References ACE_MAX, and ACE_Handler_Caching_Utility< KEY, VALUE, CONTAINER, ITERATOR, ATTRIBUTES >::minimum(). 
 00387 {
00388   // Check that the purge_percent is non-zero.
00389   if (purge_percent == 0)
00390     return 0;
00391 
00392   // Get the number of entries in the container.
00393   size_t current_map_size = container.current_size ();
00394 
00395   // Also whether the number of entries in the cache is just one!
00396   // Oops! then there is no way out but exiting. So return an error.
00397   if (current_map_size == 0)
00398     return 0;
00399 
00400   // Calculate the no of entries to remove from the cache depending
00401   // upon the <purge_percent>.
00402   size_t entries_to_remove
00403     = ACE_MAX (static_cast<size_t> (1),
00404                static_cast<size_t> (static_cast<double> (purge_percent)
00405                                     / 100 * current_map_size));
00406 
00407   KEY *key_to_remove = 0;
00408   VALUE *value_to_remove = 0;
00409 
00410   for (size_t i = 0; i < entries_to_remove ; ++i)
00411     {
00412       this->minimum (container,
00413                      key_to_remove,
00414                      value_to_remove);
00415 
00416       if (this->cleanup_strategy_->cleanup (container,
00417                                             key_to_remove,
00418                                             value_to_remove) == -1)
00419         return -1;
00420     }
00421 
00422   return 0;
00423 }
 | 
  
      
  | 
  ||||||||||||||||||||
| 
 Find the entry with minimum caching attributes. This is handler specific since this utility is to be used very specifically for handler who have caching_attributes for server side acched connection management. Definition at line 426 of file Caching_Utility_T.cpp. Referenced by ACE_Handler_Caching_Utility< KEY, VALUE, CONTAINER, ITERATOR, ATTRIBUTES >::clear_cache(). 
 00429 {
00430   // Starting values.
00431   ITERATOR iter = container.begin ();
00432   ITERATOR end = container.end ();
00433   ATTRIBUTES min = (*iter).int_id_->caching_attributes ();
00434   key_to_remove = &(*iter).ext_id_;
00435   value_to_remove = &(*iter).int_id_;
00436 
00437   // The iterator moves thru the container searching for the entry
00438   // with the lowest ATTRIBUTES.
00439   for (++iter;
00440        iter != end;
00441        ++iter)
00442     {
00443       if (min > (*iter).int_id_->caching_attributes () &&
00444           (*iter).int_id_->active () != 1)
00445         {
00446           // Ah! an item with lower ATTTRIBUTES...
00447           min = (*iter).int_id_->caching_attributes ();
00448           key_to_remove = &(*iter).ext_id_;
00449           value_to_remove = &(*iter).int_id_;
00450         }
00451     }
00452 }
 | 
  
      
  | 
  ||||||||||
| 
 
  | 
  
      
  | 
  |||||
| 
 The cleanup strategy which can be used to destroy the entries of the container. Definition at line 264 of file Caching_Utility_T.h.  | 
  
      
  | 
  |||||
| 
 Whether the cleanup_strategy should be destroyed or not. 
 Definition at line 267 of file Caching_Utility_T.h.  | 
  
 
1.3.6