Definition at line 21 of file nway_lru_cache.hpp.
Public Member Functions | |
| NWayLRU (size_t ways, size_t way_size, const Hash &hash=Hash(), const Equal &equal=Equal()) | |
| void | Put (const T &key, U value) | 
| template<typename Validator > | |
| std::optional< U > | Get (const T &key, Validator validator) | 
| std::optional< U > | Get (const T &key) | 
| U | GetOr (const T &key, const U &default_value) | 
| void | Invalidate () | 
| void | InvalidateByKey (const T &key) | 
| template<typename Function > | |
| void | VisitAll (Function func) const | 
| Iterates over all items. May be slow for big caches.   | |
| size_t | GetSize () const | 
| void | UpdateWaySize (size_t way_size) | 
| void | Write (dump::Writer &writer) const | 
| void | Read (dump::Reader &reader) | 
| void | SetDumper (std::shared_ptr< dump::Dumper > dumper) | 
| cache::NWayLRU< T, U, Hash, Eq >::NWayLRU | ( | size_t | ways, | 
| size_t | way_size, | ||
| const Hash & | hash = Hash(), | ||
| const Equal & | equal = Equal() ) | 
| ways | is the number of ways (a.k.a. shards, internal hash-maps), into which elements are distributed based on their hash. Each shard is protected by an individual mutex. Larger ways means more internal hash-map instances and more memory usage, but less contention. A good starting point is ways=16. If you encounter contention, you can increase ways to something on the order of 256 or whatever your RAM constraints allow. | 
| way_size | is the maximum allowed amount of elements per way. When the size of a way reaches this number, existing elements are deleted according to the LRU policy. | 
The maximum total number of elements is ways * way_size. 
Definition at line 92 of file nway_lru_cache.hpp.
      
  | 
  inline | 
Definition at line 44 of file nway_lru_cache.hpp.
| std::optional< U > cache::NWayLRU< T, U, Hash, Eq >::Get | ( | const T & | key, | 
| Validator | validator ) | 
Definition at line 114 of file nway_lru_cache.hpp.
| U cache::NWayLRU< T, U, Hash, Eq >::GetOr | ( | const T & | key, | 
| const U & | default_value ) | 
Definition at line 139 of file nway_lru_cache.hpp.
| size_t cache::NWayLRU< T, U, Hash, Eq >::GetSize | ( | ) | const | 
Definition at line 164 of file nway_lru_cache.hpp.
| void cache::NWayLRU< T, U, Hash, Eq >::Invalidate | ( | ) | 
Definition at line 146 of file nway_lru_cache.hpp.
| void cache::NWayLRU< T, U, Hash, Eq >::InvalidateByKey | ( | const T & | key | ) | 
Definition at line 129 of file nway_lru_cache.hpp.
| void cache::NWayLRU< T, U, Hash, Eq >::Put | ( | const T & | key, | 
| U | value ) | 
Definition at line 103 of file nway_lru_cache.hpp.
| void cache::NWayLRU< T, U, Hash, Equal >::Read | ( | dump::Reader & | reader | ) | 
Definition at line 211 of file nway_lru_cache.hpp.
| void cache::NWayLRU< T, U, Hash, Equal >::SetDumper | ( | std::shared_ptr< dump::Dumper > | dumper | ) | 
The dump::Dumper will be notified of any cache updates. This method is not thread-safe.
Definition at line 233 of file nway_lru_cache.hpp.
| void cache::NWayLRU< T, U, Hash, Eq >::UpdateWaySize | ( | size_t | way_size | ) | 
For the description of way_size, see the cache::NWayLRU::NWayLRU constructor. 
Definition at line 174 of file nway_lru_cache.hpp.
| void cache::NWayLRU< T, U, Hash, Eq >::VisitAll | ( | Function | func | ) | const | 
Iterates over all items. May be slow for big caches.
Definition at line 156 of file nway_lru_cache.hpp.
| void cache::NWayLRU< T, U, Hash, Equal >::Write | ( | dump::Writer & | writer | ) | const | 
Definition at line 195 of file nway_lru_cache.hpp.