ModErn Text Analysis
META Enumerates Textual Applications
|
Decorator class for wrapping indexes with a cache. More...
#include <cached_index.h>
Public Types | |
using | primary_key_type = typename Index::primary_key_type |
using | secondary_key_type = typename Index::secondary_key_type |
using | postings_data_type = typename Index::postings_data_type |
Public Member Functions | |
template<class... Args> | |
cached_index (cpptoml::table &config, Args &&...args) | |
Forwarding constructor: construct the Index part using the config, but then forward the additional arguments to the underlying cache. More... | |
virtual std::shared_ptr< postings_data_type > | search_primary (primary_key_type p_id) const override |
Overload for search_primary() that first attempts to find the result in the cache. More... | |
void | clear_cache () |
Clears the cache for the index. More... | |
Private Attributes | |
Cache< primary_key_type, std::shared_ptr< postings_data_type > > | cache_ |
The internal cache object. | |
Decorator class for wrapping indexes with a cache.
Like other indexes, you shouldn't construct this directly, but rather use make_index().
meta::index::cached_index< Index, Cache >::cached_index | ( | cpptoml::table & | config, |
Args &&... | args | ||
) |
Forwarding constructor: construct the Index part using the config, but then forward the additional arguments to the underlying cache.
config | the configuration that specifies how the index should be constructed |
args | The remaining arguments to send to the Cache constructor |
|
overridevirtual |
Overload for search_primary() that first attempts to find the result in the cache.
Failing that, it will invoke the base class search_primary(), store the result in the cache, and then return the value.
p_id | the primary key to search the postings file for |
void meta::index::cached_index< Index, Cache >::clear_cache | ( | ) |
Clears the cache for the index.
Useful if you're using something like no-evict cache and want to reclaim memory.