12#include "MantidKernel/DllConfig.h"
27template <
class KEYTYPE,
class VALUETYPE>
class Cache {
57 std::lock_guard<std::mutex> lock(
m_mutex);
86 std::lock_guard<std::mutex> lock(
m_mutex);
120 std::lock_guard<std::mutex> lock(
m_mutex);
133 std::lock_guard<std::mutex> lock(
m_mutex);
138 value = it_found->second;
const std::vector< double > & rhs
double value
The value of the point.
Cache is a generic caching storage class.
Cache()
No-arg Constructor.
void setCache(const KEYTYPE &key, const VALUETYPE &value)
Inserts/updates a cached value with the given key.
void clear()
Clears the cache.
int m_cacheMiss
total number of times the cache has not contained the requested information
void removeCache(const KEYTYPE &key)
Attempts to remove a value from the cache.
std::map< KEYTYPE, VALUETYPE > m_cacheMap
internal cache map
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
std::mutex m_mutex
internal mutex
Cache< KEYTYPE, VALUETYPE > & operator=(const Cache< KEYTYPE, VALUETYPE > &rhs)
Copy-assignment operator as we have a non-default copy constructor.
Cache(const Cache< KEYTYPE, VALUETYPE > &src)
Copy constructor (mutex cannot be copied)
bool getCacheNoStats(const KEYTYPE key, VALUETYPE &value) const
Attempts to retrieve a value from the cache.
int size()
The number of cache entries.
typename std::map< KEYTYPE, VALUETYPE >::const_iterator CacheMapConstIterator
const_iterator typedef
int hitCount()
total number of times the cache has contained the requested information
bool getCache(const KEYTYPE &key, VALUETYPE &value) const
Attempts to retrieve a value from the cache, with optional cache stats tracking.
typename std::map< KEYTYPE, VALUETYPE >::iterator CacheMapIterator
iterator typedef
int m_cacheHit
total number of times the cache has contained the requested information
Helper class which provides the Collimation Length for SANS instruments.