|
ModErn Text Analysis
META Enumerates Textual Applications
|
A simple sharding-based approach for increasing concurrency within a cache. More...
#include <shard_cache.h>
Public Member Functions | |
| template<class... Args> | |
| generic_shard_cache (uint8_t shards, Args &&...args) | |
| Constructs a shard cache with the given number of shards, passing any additional parameters to the underlying Map classes created. More... | |
| generic_shard_cache (generic_shard_cache &&)=default | |
| generic_shard_cache may be move constructed | |
| generic_shard_cache & | operator= (generic_shard_cache &&)=default |
| generic_shard_cache may be move assigned | |
| ~generic_shard_cache ()=default | |
| Default destructor. | |
| void | insert (const Key &key, const Value &value) |
| Inserts a given (key, value) pair into the cache. More... | |
| util::optional< Value > | find (const Key &key) |
| Finds a value in the cache. More... | |
Private Attributes | |
| std::vector< Map< Key, Value > > | shards_ |
| The Map for each shard. | |
| std::hash< Key > | hasher_ |
| The hash function used for determining which shard a key belongs to. | |
A simple sharding-based approach for increasing concurrency within a cache.
Wraps a given number of Maps, each used to contain a segment of the keyspace. It is assumed that the Map class is self-synchronizing (i.e., it has a mutex or other concurrency safety mechanism built in).
| meta::caching::generic_shard_cache< Key, Value, Map >::generic_shard_cache | ( | uint8_t | shards, |
| Args &&... | args | ||
| ) |
Constructs a shard cache with the given number of shards, passing any additional parameters to the underlying Map classes created.
| shards | the number of shards to create |
| args | the remaining arguments to be used in creating the Map for each shard |
| void meta::caching::generic_shard_cache< Key, Value, Map >::insert | ( | const Key & | key, |
| const Value & | value | ||
| ) |
Inserts a given (key, value) pair into the cache.
| key | |
| value |
| util::optional< Value > meta::caching::generic_shard_cache< Key, Value, Map >::find | ( | const Key & | key | ) |
Finds a value in the cache.
If it exists, the optional will be engaged, otherwise, it will be disengaged.
| key | the key to find the corresponding value for |
1.8.9.1