Cache.cpp
Go to the documentation of this file.
1 #include <NovaDAQUtilities/Cache.h>
2 
3 namespace novadaq {
4 
5 /**
6  * Flushes the cache. (Removes any saved data.)
7  */
8 void Cache::flush() {
9  boost::mutex::scoped_lock lock(_cacheMutex);
11  _cacheIsEmpty = true;
12 }
13 
14 /**
15  * Constructor.
16  *
17  * @param policy the CachePolicy to use for automatically expiring
18  * the cache.
19  */
20 Cache::Cache(CachePolicy policy) : _policy(policy), _cacheIsEmpty(true) {}
21 
22 /**
23  * Reloads the cache if needed.
24  */
26  if (_cacheIsEmpty || _policy.isExpired()) {
29  _cacheIsEmpty = false;
31  }
32 }
33 
34 } // end of namespace novadaq
void flush()
Definition: Cache.cpp:8
bool _cacheIsEmpty
Definition: Cache.h:40
virtual void _clearCachedData()=0
Cache(CachePolicy policy)
Definition: Cache.cpp:20
void _reloadIfNeeded()
Definition: Cache.cpp:25
CachePolicy _policy
Definition: Cache.h:39
virtual void _loadDataIntoCache()=0
boost::mutex _cacheMutex
Definition: Cache.h:41