Collaboration diagram for Generic Cache:
|
Files | |
| file | ncbi_cache.hpp |
| The NCBI C++ generic cache template. | |
Classes | |
| struct | SCacheElement< TKey, TSize > |
| Internal structure to hold cache elements. More... | |
| struct | CCacheElement_Less< TCacheElementPtr > |
| Compare cache elements by weight/order. More... | |
| class | CCacheElement_Handler< TKey, TValue > |
| Default (NOP) element handler. More... | |
| class | CCache< TKey, TValue, THandler, TLock, TSize > |
| Cache template. More... | |
| class | CCacheException |
| Exception thrown by CCache. More... | |
Typedefs | |
| typedef CMutex | TCacheLock_Default |
| Default cache lock. | |
Enumerations | |
| enum | ECache_InsertFlag { eCache_CheckSize, eCache_CanInsert, eCache_NeedCleanup, eCache_DoNotCache } |
| Flag indicating if an element can be inserted into cache. More... | |
Functions | |
| CCache::CCache (TSizeType capacity, THandler *handler=new THandler()) | |
| Create cache object with the given capacity. | |
| CCache::~CCache (void) | |
| void | CCache::x_EraseElement (TCacheSet_I &set_iter, TCacheMap_I &map_iter) |
| void | CCache::x_EraseLast (void) |
| TCacheElement * | CCache::x_InsertElement (const TKeyType &key, TWeight weight) |
| void | CCache::x_UpdateElement (TCacheElement *elem) |
| TOrder | CCache::x_GetNextCounter (void) |
| void | CCache::x_PackElementIndex (void) |
| TOrder | CCache::Add (const TKeyType &key, const TValueType &value, TWeight weight=1, TAddFlags add_flags=0, EAddResult *result=NULL) |
| Add new element to the cache or replace the existing value. | |
| TValueType | CCache::operator[] (const TKeyType &key) |
| Get cache element by the key. | |
| TValueType | CCache::Get (const TKeyType &key, TGetFlags get_flags=0, EGetResult *result=NULL) |
| Get an object from the cache by its key. | |
| bool | CCache::Remove (const TKeyType &key) |
| Remove element from cache. Do nothing if the key is not cached. | |
| void | CCache::SetCapacity (TSizeType new_capacity) |
| Set new capacity of the cache. | |
| void | CCache::SetSize (TSizeType new_size) |
| Truncate the cache leaving at most new_size elements. | |
|
|
Default cache lock.
Definition at line 134 of file ncbi_cache.hpp. |
|
|
Flag indicating if an element can be inserted into cache.
Definition at line 96 of file ncbi_cache.hpp. |
|
||||||||||||||||||||||||||||
|
Add new element to the cache or replace the existing value.
Definition at line 506 of file ncbi_cache.hpp. References CCache< TKey, TValue, THandler, TLock, TSize >::eAdd_NotInserted, CCache< TKey, TValue, THandler, TLock, TSize >::eAdd_Replaced, map_checker< Container >::end(), CCache< TKey, TValue, THandler, TLock, TSize >::fAdd_NoReplace, set< Key, Compare >::find(), map_checker< Container >::find(), CCache< TKey, TValue, THandler, TLock, TSize >::m_CacheMap, CCache< TKey, TValue, THandler, TLock, TSize >::m_CacheSet, CCache< TKey, TValue, THandler, TLock, TSize >::m_Lock, and CCache< TKey, TValue, THandler, TLock, TSize >::x_EraseElement(). |
|
||||||||||||||||
|
Create cache object with the given capacity.
Definition at line 326 of file ncbi_cache.hpp. References _ASSERT, CCache< TKey, TValue, THandler, TLock, TSize >::m_Handler, and auto_ptr< X >::reset(). |
|
||||||||||||||||||||
|
Get an object from the cache by its key. Depending on flags create and cache a new value if the key is not found. If the flags do not allow creating new elements, throws an exception.
Definition at line 589 of file ncbi_cache.hpp. References CCache< TKey, TValue, THandler, TLock, TSize >::eGet_Found, map_checker< Container >::end(), CCache< TKey, TValue, THandler, TLock, TSize >::fGet_NoTouch, map_checker< Container >::find(), CCache< TKey, TValue, THandler, TLock, TSize >::m_CacheMap, CCache< TKey, TValue, THandler, TLock, TSize >::m_Lock, and CCache< TKey, TValue, THandler, TLock, TSize >::x_UpdateElement(). |
|
||||||||||
|
Get cache element by the key. If the key is not cached yet, the handler's CreateValue() will be called to create one and the new element will be stored in the cache.
Definition at line 572 of file ncbi_cache.hpp. References map_checker< Container >::end(), map_checker< Container >::find(), CCache< TKey, TValue, THandler, TLock, TSize >::m_CacheMap, CCache< TKey, TValue, THandler, TLock, TSize >::m_Lock, and CCache< TKey, TValue, THandler, TLock, TSize >::x_UpdateElement(). |
|
||||||||||
|
Remove element from cache. Do nothing if the key is not cached.
Definition at line 630 of file ncbi_cache.hpp. References map_checker< Container >::end(), map_checker< Container >::find(), CCache< TKey, TValue, THandler, TLock, TSize >::m_CacheMap, and CCache< TKey, TValue, THandler, TLock, TSize >::m_Lock. |
|
||||||||||
|
Set new capacity of the cache. The number of elements in the cache may be reduced to match the new capacity.
Definition at line 645 of file ncbi_cache.hpp. References CCache< TKey, TValue, THandler, TLock, TSize >::GetSize(), CCache< TKey, TValue, THandler, TLock, TSize >::m_Capacity, CCache< TKey, TValue, THandler, TLock, TSize >::m_Lock, NCBI_THROW, and CCache< TKey, TValue, THandler, TLock, TSize >::x_EraseLast(). |
|
||||||||||
|
Truncate the cache leaving at most new_size elements. Does not affect cache capacity. If new_size is zero all elements will be removed. Definition at line 660 of file ncbi_cache.hpp. References CCache< TKey, TValue, THandler, TLock, TSize >::GetSize(), CCache< TKey, TValue, THandler, TLock, TSize >::m_Lock, and CCache< TKey, TValue, THandler, TLock, TSize >::x_EraseLast(). |
|
||||||||||||||||
|
||||||||||
|
||||||||||
|
Definition at line 419 of file ncbi_cache.hpp. References CCache< TKey, TValue, THandler, TLock, TSize >::m_Counter, and CCache< TKey, TValue, THandler, TLock, TSize >::x_PackElementIndex(). Referenced by CCache< TKey, TValue, THandler, TLock, TSize >::x_InsertElement(), and CCache< TKey, TValue, THandler, TLock, TSize >::x_UpdateElement(). |
|
||||||||||||||||
|
||||||||||
|
||||||||||
|
||||||||||
1.4.6
Modified on Mon Dec 07 16:24:36 2009 by modify_doxy.py rev. 173732