|
| Cache (size_t maxSize) |
| Create a new cache object with the given max size.
|
|
void | DumpStatistics (const char *cacheName, const ValueSizer &sizer) |
| Dump some cache statistics to std::cout.
|
|
void | Flush () |
| Completely flush the cache removing all entries from it.
|
|
bool | GetEntry (const K &key, CacheRef &reference) |
| Getting the value with the given key from cache.
|
|
size_t | GetMaxSize () const |
| Returns the maximum size of the cache.
|
|
size_t | GetMemory (const ValueSizer &sizer) const |
|
size_t | GetSize () const |
| Returns the current size of the cache.
|
|
bool | IsActive () const |
| Returns if the cache is active (maxSize > 0)
|
|
Cache::CacheRef | SetEntry (const CacheEntry &entry) |
| Set or update the cache with the given value for the given key.
|
|
void | SetMaxSize (size_t maxSize) |
| Set a new cache max size, possible striping the oldest entries from cache if the new size is smaller than the old one.
|
|
template<class K, class V, class IK = PageId>
class osmscout::Cache< K, V, IK >
Generic FIFO cache implementation with O(n log n) semantic.
Template parameter class K holds the key value (must be a numerical value), parameter class V holds the data class that is to be cached, and parameter IK holds the internal key value, must be an unsigned value, default is PageId.
- The cache is not threadsafe.
- It uses a std::vector<std::list>> as a hash table for data lookup
- It uses an std::list for implementing FIFO characteristics.
Implementation details: If std::unordered_map ist available we use this for fast detection (O(1)) if an object is already in the cast. If it is not available, we use a vector as a hashtable via the key value with list as entry type for hash code conflict handling.
template<class K , class V , class IK = PageId>
Getting the value with the given key from cache.
If there is no valued stored with the given key, false will be returned and the reference will be untouched.
If there is a value with the given key, reference will return a reference to the value and the value will moved to the front position of the cache to assure FIFO behaviour.
References osmscout::Cache< K, V, IK >::IsActive().
template<class K , class V , class IK = PageId>