A thread-safe LRU cache.
More...
#include <lru_cache.h>
|
| | LRUCache () noexcept |
| | Construct a new LRUCache object.
|
| |
| | LRUCache (size_type capacity) |
| | Construct a new LRUCache object given a capacity.
|
| |
|
| LRUCache (LRUCache &&) noexcept=default |
| | Move-construct a LRUCache object.
|
| |
|
LRUCache & | operator= (LRUCache &&) noexcept=default |
| | Move-assign a LRUCache object.
|
| |
|
| LRUCache (const LRUCache &)=delete |
| | Deleted copy constructor.
|
| |
|
LRUCache & | operator= (const LRUCache &)=delete |
| | Deleted copy assignment operator.
|
| |
|
| ~LRUCache () noexcept=default |
| | Destroy the LRUCache object.
|
| |
| template<SameNoCVRefQuals< key_type > K, std::convertible_to< mapped_type > V> |
| void | put (K &&key, V &&value) |
| | Put a key-value pair into the cache.
|
| |
| template<SameNoCVRefQuals< key_type > K> |
| mapped_type | get (K &&key) |
| | Get a value from the cache.
|
| |
| template<SameNoCVRefQuals< key_type > K> |
| bool | contains (K &&key) const noexcept |
| | Check if the cache contains a key.
|
| |
| size_type | capacity () const noexcept |
| | Remove a key from the cache.
|
| |
| size_type | size () const noexcept |
| | Get the size of the cache.
|
| |
| void | clear () noexcept |
| | Clear the cache.
|
| |
A thread-safe LRU cache.
- Template Parameters
-
| TKey | Key type. |
| TValue | Value type. |
Definition at line 20 of file lru_cache.h.
◆ key_type
◆ mapped_type
| using vkdb::LRUCache< TKey, TValue >::mapped_type = std::optional<TValue> |
◆ size_type
◆ value_type
| using vkdb::LRUCache< TKey, TValue >::value_type = std::pair<const key_type, mapped_type> |
◆ LRUCache() [1/2]
◆ LRUCache() [2/2]
Construct a new LRUCache object given a capacity.
- Parameters
-
- Exceptions
-
| std::invalid_argument | If the capacity is 0. |
Definition at line 42 of file lru_cache.h.
◆ capacity()
Remove a key from the cache.
- Template Parameters
-
- Parameters
-
Definition at line 145 of file lru_cache.h.
◆ clear()
◆ contains()
Check if the cache contains a key.
- Template Parameters
-
- Parameters
-
- Returns
- true if the cache contains the key.
-
false if the cache does not contain the key.
Definition at line 134 of file lru_cache.h.
◆ get()
Get a value from the cache.
- Template Parameters
-
- Parameters
-
- Returns
- mapped_type The value if it exists, std::nullopt otherwise.
Definition at line 115 of file lru_cache.h.
◆ put()
Put a key-value pair into the cache.
- Template Parameters
-
| K | Key type. |
| V | Value-convertible type. |
- Parameters
-
- Exceptions
-
| std::exception | If inserting the key-value pair fails. |
Definition at line 93 of file lru_cache.h.
◆ size()
Get the size of the cache.
- Returns
- size_type The size of the cache.
Definition at line 155 of file lru_cache.h.
The documentation for this class was generated from the following file:
- /home/runner/work/vkdb/vkdb/include/storage/vkdb/lru_cache.h