ModErn Text Analysis
META Enumerates Textual Applications
no_evict_cache.h
Go to the documentation of this file.
1 
10 #ifndef META_NO_EVICT_CACHE_H_
11 #define META_NO_EVICT_CACHE_H_
12 
13 #include <deque>
14 #include <memory>
15 #include <mutex>
16 
17 #include "meta.h"
18 #include "util/optional.h"
19 #include "util/shim.h"
20 
21 namespace meta
22 {
23 namespace caching
24 {
25 
31 template <class Key, class Value>
33 {
34  public:
35  static_assert((std::is_integral<Key>::value
36  || std::is_base_of<util::numeric, Key>::value),
37  "Key for no_evict_cache must be a numeric type");
38 
46  void insert(const Key& key, const Value& value);
47 
53  util::optional<Value> find(const Key& key) const;
54 
58  void clear();
59 
60  private:
64  std::unique_ptr<std::mutex> mutables_{make_unique<std::mutex>()};
65 
69  std::deque<util::optional<Value>> values_;
70 };
71 }
72 }
73 #include "caching/no_evict_cache.tcc"
74 #endif
std::unique_ptr< std::mutex > mutables_
Mutex for locking operations.
Definition: no_evict_cache.h:64
Contains top-level namespace documentation for the META toolkit.
std::deque< util::optional< Value > > values_
Contains all of the values inserted thus far.
Definition: no_evict_cache.h:69
The ModErn Text Analysis toolkit is a suite of natural language processing, classification, information retreival, data mining, and other applications of text processing.
Definition: analyzer.h:24
void insert(const Key &key, const Value &value)
Inserts the given key, value pair into the cache.
Definition: no_evict_cache.tcc:9
void clear()
Clears the cache.
Definition: no_evict_cache.tcc:26
util::optional< Value > find(const Key &key) const
Finds the value associated with the given key.
Definition: no_evict_cache.tcc:18
An incredibly simple "cache" that simply keeps everything in memory.
Definition: no_evict_cache.h:32