27#include <unordered_map>
34template <
typename Data_extension>
36 std::unordered_map<meta::Metadata, Data_extension, meta::Metadata::Hash>;
38template <
typename Data_extension = data::Data>
63 auto it =
cache_.find(metadata);
64 if (it ==
cache_.end())
return false;
79 bool ok =
cache_.insert({metadata, data}).second;
93 bool removed =
cache_.erase(metadata) != 0;
124 return cache_.find(metadata);
bool erase(const meta::Metadata metadata)
Remove an entry from cache.
Definition: cache.h:92
Cache< Data_extension >::const_iterator at(const meta::Metadata metadata) const
Retrieve iterator at an element from cache.
Definition: cache.h:122
Datacache & operator=(const Datacache &src)=delete
void clear()
Clear the cache.
Definition: cache.h:99
Cache< Data_extension >::const_iterator begin() const
Definition: cache.h:111
size_t version() const
Get cache version.
Definition: cache.h:108
Cache< Data_extension > cache_
Sensitive data cache.
Definition: cache.h:129
size_t size() const
Get size.
Definition: cache.h:105
~Datacache()=default
Destructor.
Datacache(const Datacache &src)=delete
Disable copy.
Datacache(Datacache &&src)=delete
bool store(const meta::Metadata metadata, const Data_extension data)
Store and element in cache.
Definition: cache.h:78
Cache< Data_extension >::const_iterator end() const
Definition: cache.h:114
Datacache & operator=(Datacache &&src)=delete
bool empty() const
Check if cache is empty.
Definition: cache.h:102
Datacache()
Constructor.
Definition: cache.h:42
size_t version_
Cache version.
Definition: cache.h:131
bool get(const meta::Metadata metadata, Data_extension &data) const
Retrieve an element from cache.
Definition: cache.h:62
std::unordered_map< meta::Metadata, Data_extension, meta::Metadata::Hash > Cache
Definition: cache.h:36