OmniSciDB  a5dc49c757
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DictionaryCache< key_t, value_t > Class Template Reference

#include <DictionaryCache.hpp>

Public Member Functions

 DictionaryCache ()
 
void put (const key_t &key, const std::shared_ptr< value_t > value)
 
std::shared_ptr< value_t > get (const key_t &key)
 
void remove (const key_t &key)
 
bool is_empty ()
 
void invalidateInvertedIndex () noexcept
 

Private Attributes

std::unordered_map< key_t,
std::shared_ptr< value_t > > 
cache_items
 

Detailed Description

template<typename key_t, typename value_t>
class DictionaryCache< key_t, value_t >

Definition at line 26 of file DictionaryCache.hpp.

Constructor & Destructor Documentation

template<typename key_t, typename value_t>
DictionaryCache< key_t, value_t >::DictionaryCache ( )
inline

Definition at line 28 of file DictionaryCache.hpp.

28 {}

Member Function Documentation

template<typename key_t, typename value_t>
std::shared_ptr<value_t> DictionaryCache< key_t, value_t >::get ( const key_t &  key)
inline

Definition at line 38 of file DictionaryCache.hpp.

38  {
39  auto it = cache_items.find(key);
40  if (it == cache_items.end()) {
41  return nullptr;
42  }
43  return it->second;
44  }
std::unordered_map< key_t, std::shared_ptr< value_t > > cache_items
template<typename key_t, typename value_t>
void DictionaryCache< key_t, value_t >::invalidateInvertedIndex ( )
inlinenoexcept

Definition at line 50 of file DictionaryCache.hpp.

50  {
51  if (!cache_items.empty()) {
52  cache_items.clear();
53  }
54  }
std::unordered_map< key_t, std::shared_ptr< value_t > > cache_items
template<typename key_t, typename value_t>
bool DictionaryCache< key_t, value_t >::is_empty ( )
inline

Definition at line 48 of file DictionaryCache.hpp.

48 { return cache_items.empty(); }
std::unordered_map< key_t, std::shared_ptr< value_t > > cache_items
template<typename key_t, typename value_t>
void DictionaryCache< key_t, value_t >::put ( const key_t &  key,
const std::shared_ptr< value_t >  value 
)
inline

Definition at line 30 of file DictionaryCache.hpp.

30  {
31  auto it = cache_items.find(key);
32  if (it != cache_items.end()) {
33  cache_items.erase(it);
34  }
35  cache_items.insert({key, value});
36  }
std::unordered_map< key_t, std::shared_ptr< value_t > > cache_items
template<typename key_t, typename value_t>
void DictionaryCache< key_t, value_t >::remove ( const key_t &  key)
inline

Definition at line 46 of file DictionaryCache.hpp.

46 { cache_items.erase(key); }
std::unordered_map< key_t, std::shared_ptr< value_t > > cache_items

Member Data Documentation


The documentation for this class was generated from the following file: