ModErn Text Analysis
META Enumerates Textual Applications
Public Member Functions | Private Attributes | List of all members
meta::caching::no_evict_cache< Key, Value > Class Template Reference

An incredibly simple "cache" that simply keeps everything in memory. More...

#include <no_evict_cache.h>

Public Member Functions

void insert (const Key &key, const Value &value)
 Inserts the given key, value pair into the cache. More...
 
util::optional< Value > find (const Key &key) const
 Finds the value associated with the given key. More...
 
void clear ()
 Clears the cache.
 

Private Attributes

std::unique_ptr< std::mutex > mutables_ {make_unique<std::mutex>()}
 Mutex for locking operations.
 
std::deque< util::optional< Value > > values_
 Contains all of the values inserted thus far. More...
 

Detailed Description

template<class Key, class Value>
class meta::caching::no_evict_cache< Key, Value >

An incredibly simple "cache" that simply keeps everything in memory.

Useful for when the dataset is small enough that we have enough RAM to fit it in-core.

Member Function Documentation

template<class Key , class Value >
void meta::caching::no_evict_cache< Key, Value >::insert ( const Key &  key,
const Value &  value 
)

Inserts the given key, value pair into the cache.

May be slow while the cache is initially populated as it needs to resize the internal storage.

Parameters
keythe key to insert
valuethe value to insert
template<class Key , class Value >
util::optional< Value > meta::caching::no_evict_cache< Key, Value >::find ( const Key &  key) const

Finds the value associated with the given key.

Parameters
keythe key to find the associated value for, if it exists
Returns
an optional that may contain the value, if found

Member Data Documentation

template<class Key , class Value >
std::deque<util::optional<Value> > meta::caching::no_evict_cache< Key, Value >::values_
private

Contains all of the values inserted thus far.

Never shrinks.


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