27#include <unordered_map>
35template <
typename Data_extension>
37 std::unordered_map<meta::Metadata, Data_extension, meta::Metadata::Hash>;
39template <
typename Data_extension = data::Data>
75 auto it =
cache_.find(metadata);
76 if (it ==
cache_.end())
return false;
91 bool ok =
cache_.insert({metadata, data}).second;
105 bool removed =
cache_.erase(metadata) != 0;
136 return cache_.find(metadata);
bool erase(const meta::Metadata metadata)
Remove an entry from cache.
Definition: cache.h:104
Cache< Data_extension >::const_iterator at(const meta::Metadata metadata) const
Retrieve iterator at an element from cache.
Definition: cache.h:134
Datacache & operator=(const Datacache &src)=delete
void clear()
Clear the cache.
Definition: cache.h:111
Cache< Data_extension >::const_iterator begin() const
Definition: cache.h:123
static void swap(Datacache &a, Datacache &b)
Swap content of two caches.
Definition: cache.h:60
size_t version() const
Get cache version.
Definition: cache.h:120
Cache< Data_extension > cache_
Sensitive data cache.
Definition: cache.h:141
size_t size() const
Get size.
Definition: cache.h:117
~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:90
Cache< Data_extension >::const_iterator end() const
Definition: cache.h:126
Datacache & operator=(Datacache &&src)=delete
bool empty() const
Check if cache is empty.
Definition: cache.h:114
Datacache()
Constructor.
Definition: cache.h:43
size_t version_
Cache version.
Definition: cache.h:143
bool get(const meta::Metadata metadata, Data_extension &data) const
Retrieve an element from cache.
Definition: cache.h:74
std::unordered_map< meta::Metadata, Data_extension, meta::Metadata::Hash > Cache
Definition: cache.h:37
static void swap(String &a, String &b) noexcept
Definition: sql_string.h:663