|
Mantid
|
Cache is a generic caching storage class. More...
#include <Kernel/Cache.h>
Public Member Functions | |
| Cache () | |
| No-arg Constructor. | |
| Cache (const Cache< KEYTYPE, VALUETYPE > &src) | |
| Copy constructor (mutex cannot be copied) | |
| void | clear () |
| Clears the cache. | |
| bool | getCache (const KEYTYPE &key, VALUETYPE &value) const |
| Attempts to retrieve a value from the cache, with optional cache stats tracking. | |
| int | hitCount () |
| total number of times the cache has contained the requested information | |
| double | hitRatio () |
| total number of times the cache has contained the requested information/the total number of requests | |
| int | missCount () |
| total number of times the cache has contained the requested information | |
| Cache< KEYTYPE, VALUETYPE > & | operator= (const Cache< KEYTYPE, VALUETYPE > &rhs) |
| Copy-assignment operator as we have a non-default copy constructor. | |
| void | removeCache (const KEYTYPE &key) |
| Attempts to remove a value from the cache. | |
| void | setCache (const KEYTYPE &key, const VALUETYPE &value) |
| Inserts/updates a cached value with the given key. | |
| int | size () |
| The number of cache entries. | |
Private Types | |
| using | CacheMapConstIterator = typename std::map< KEYTYPE, VALUETYPE >::const_iterator |
| const_iterator typedef | |
| using | CacheMapIterator = typename std::map< KEYTYPE, VALUETYPE >::iterator |
| iterator typedef | |
Private Member Functions | |
| bool | getCacheNoStats (const KEYTYPE key, VALUETYPE &value) const |
| Attempts to retrieve a value from the cache. | |
Private Attributes | |
| int | m_cacheHit |
| total number of times the cache has contained the requested information | |
| std::map< KEYTYPE, VALUETYPE > | m_cacheMap |
| internal cache map | |
| int | m_cacheMiss |
| total number of times the cache has not contained the requested information | |
| std::mutex | m_mutex |
| internal mutex | |
Cache is a generic caching storage class.
|
private |
|
private |
|
inline |
|
inline |
|
inline |
Clears the cache.
Definition at line 56 of file Cache.h.
References Mantid::Kernel::Cache< KEYTYPE, VALUETYPE >::m_cacheHit, Mantid::Kernel::Cache< KEYTYPE, VALUETYPE >::m_cacheMap, Mantid::Kernel::Cache< KEYTYPE, VALUETYPE >::m_cacheMiss, and Mantid::Kernel::Cache< KEYTYPE, VALUETYPE >::m_mutex.
|
inline |
Attempts to retrieve a value from the cache, with optional cache stats tracking.
| key | The key for the requested value |
| value | An output reference for the value, set to the curretn value if found, otherwise it is untouched |
Definition at line 98 of file Cache.h.
References Mantid::Kernel::Cache< KEYTYPE, VALUETYPE >::getCacheNoStats(), Mantid::Kernel::Cache< KEYTYPE, VALUETYPE >::m_cacheHit, Mantid::Kernel::Cache< KEYTYPE, VALUETYPE >::m_cacheMiss, PARALLEL_ATOMIC, and value.
|
inlineprivate |
Attempts to retrieve a value from the cache.
| key | The key for the requested value |
| value | An output reference for the value, set to the curretn value if found, otherwise it is untouched |
Definition at line 132 of file Cache.h.
References Mantid::Kernel::Cache< KEYTYPE, VALUETYPE >::m_cacheMap, Mantid::Kernel::Cache< KEYTYPE, VALUETYPE >::m_mutex, and value.
Referenced by Mantid::Kernel::Cache< KEYTYPE, VALUETYPE >::getCache().
|
inline |
total number of times the cache has contained the requested information
Definition at line 67 of file Cache.h.
References Mantid::Kernel::Cache< KEYTYPE, VALUETYPE >::m_cacheHit.
|
inline |
total number of times the cache has contained the requested information/the total number of requests
Definition at line 72 of file Cache.h.
References Mantid::Kernel::Cache< KEYTYPE, VALUETYPE >::hitRatio(), Mantid::Kernel::Cache< KEYTYPE, VALUETYPE >::m_cacheHit, and Mantid::Kernel::Cache< KEYTYPE, VALUETYPE >::m_cacheMiss.
Referenced by Mantid::Kernel::Cache< KEYTYPE, VALUETYPE >::hitRatio().
|
inline |
total number of times the cache has contained the requested information
Definition at line 69 of file Cache.h.
References Mantid::Kernel::Cache< KEYTYPE, VALUETYPE >::m_cacheMiss.
|
inline |
Copy-assignment operator as we have a non-default copy constructor.
| rhs | The object that is on the RHS of the assignment |
Definition at line 45 of file Cache.h.
References Mantid::Kernel::Cache< KEYTYPE, VALUETYPE >::m_cacheHit, Mantid::Kernel::Cache< KEYTYPE, VALUETYPE >::m_cacheMap, Mantid::Kernel::Cache< KEYTYPE, VALUETYPE >::m_cacheMiss, and rhs.
|
inline |
Attempts to remove a value from the cache.
If the key does not exist, it does nothing
| key | The key whose value should be removed |
Definition at line 119 of file Cache.h.
References Mantid::Kernel::Cache< KEYTYPE, VALUETYPE >::m_cacheMap, and Mantid::Kernel::Cache< KEYTYPE, VALUETYPE >::m_mutex.
|
inline |
Inserts/updates a cached value with the given key.
| key | The key |
| value | The new value for the key |
Definition at line 85 of file Cache.h.
References Mantid::Kernel::Cache< KEYTYPE, VALUETYPE >::m_cacheMap, Mantid::Kernel::Cache< KEYTYPE, VALUETYPE >::m_mutex, and value.
|
inline |
The number of cache entries.
Definition at line 64 of file Cache.h.
References Mantid::Kernel::Cache< KEYTYPE, VALUETYPE >::m_cacheMap.
|
mutableprivate |
total number of times the cache has contained the requested information
Definition at line 145 of file Cache.h.
Referenced by Mantid::Kernel::Cache< KEYTYPE, VALUETYPE >::clear(), Mantid::Kernel::Cache< KEYTYPE, VALUETYPE >::getCache(), Mantid::Kernel::Cache< KEYTYPE, VALUETYPE >::hitCount(), Mantid::Kernel::Cache< KEYTYPE, VALUETYPE >::hitRatio(), and Mantid::Kernel::Cache< KEYTYPE, VALUETYPE >::operator=().
|
private |
internal cache map
Definition at line 150 of file Cache.h.
Referenced by Mantid::Kernel::Cache< KEYTYPE, VALUETYPE >::clear(), Mantid::Kernel::Cache< KEYTYPE, VALUETYPE >::getCacheNoStats(), Mantid::Kernel::Cache< KEYTYPE, VALUETYPE >::operator=(), Mantid::Kernel::Cache< KEYTYPE, VALUETYPE >::removeCache(), Mantid::Kernel::Cache< KEYTYPE, VALUETYPE >::setCache(), and Mantid::Kernel::Cache< KEYTYPE, VALUETYPE >::size().
|
mutableprivate |
total number of times the cache has not contained the requested information
Definition at line 148 of file Cache.h.
Referenced by Mantid::Kernel::Cache< KEYTYPE, VALUETYPE >::clear(), Mantid::Kernel::Cache< KEYTYPE, VALUETYPE >::getCache(), Mantid::Kernel::Cache< KEYTYPE, VALUETYPE >::hitRatio(), Mantid::Kernel::Cache< KEYTYPE, VALUETYPE >::missCount(), and Mantid::Kernel::Cache< KEYTYPE, VALUETYPE >::operator=().
|
mutableprivate |
internal mutex
Definition at line 152 of file Cache.h.
Referenced by Mantid::Kernel::Cache< KEYTYPE, VALUETYPE >::clear(), Mantid::Kernel::Cache< KEYTYPE, VALUETYPE >::getCacheNoStats(), Mantid::Kernel::Cache< KEYTYPE, VALUETYPE >::removeCache(), and Mantid::Kernel::Cache< KEYTYPE, VALUETYPE >::setCache().