proxygen
|
#include <LRUInMemoryCache.h>
Public Member Functions | |
LRUInMemoryCache (size_t capacity) | |
~LRUInMemoryCache ()=default | |
folly::Optional< V > | get (const K &key) |
void | put (const K &key, const V &val) |
bool | remove (const K &key) |
size_t | size () const |
void | clear () |
CacheDataVersion | getVersion () const |
CacheDataVersion | loadData (const folly::dynamic &kvPairs) noexcept |
folly::Optional< std::pair< folly::dynamic, CacheDataVersion > > | convertToKeyValuePairs () noexcept |
bool | hasChangedSince (CacheDataVersion version) const |
Private Member Functions | |
void | incrementVersion () |
Private Attributes | |
folly::EvictingCacheMap< K, V > | cache_ |
CacheDataVersion | version_ {1} |
MutexT | cacheLock_ |
A threadsafe cache map that delegates to an EvictingCacheMap and maintains a version of the data.
Definition at line 32 of file LRUInMemoryCache.h.
|
inlineexplicit |
Create with the specified capacity.
Definition at line 37 of file LRUInMemoryCache.h.
|
default |
Referenced by wangle::LRUInMemoryCache< K, V, M >::LRUInMemoryCache().
void wangle::LRUInMemoryCache< K, V, M >::clear | ( | ) |
Definition at line 59 of file LRUInMemoryCache-inl.h.
Referenced by wangle::LRUInMemoryCache< K, V, M >::LRUInMemoryCache().
|
noexcept |
Get the cache data as a list of kv pairs along with the version
Definition at line 105 of file LRUInMemoryCache-inl.h.
References folly::dynamic::array(), folly::gen::move, folly::none, folly::dynamic::push_back(), and folly::toDynamic().
Referenced by wangle::LRUInMemoryCache< K, V, M >::LRUInMemoryCache().
folly::Optional< V > wangle::LRUInMemoryCache< K, V, M >::get | ( | const K & | key | ) |
Definition at line 24 of file LRUInMemoryCache-inl.h.
References folly::none.
CacheDataVersion wangle::LRUInMemoryCache< K, V, M >::getVersion | ( | ) | const |
Definition at line 69 of file LRUInMemoryCache-inl.h.
Referenced by wangle::LRUInMemoryCache< K, V, M >::hasChangedSince(), and wangle::LRUInMemoryCache< K, V, M >::LRUInMemoryCache().
|
inline |
Determine if the cache has changed since the specified version
Definition at line 63 of file LRUInMemoryCache.h.
|
inlineprivate |
Definition at line 70 of file LRUInMemoryCache.h.
|
noexcept |
Loads the list of kv pairs into the cache and bumps version. Returns the new cache version.
Definition at line 76 of file LRUInMemoryCache-inl.h.
References data.
Referenced by wangle::LRUInMemoryCache< K, V, M >::LRUInMemoryCache().
void wangle::LRUInMemoryCache< K, V, M >::put | ( | const K & | key, |
const V & | val | ||
) |
Definition at line 35 of file LRUInMemoryCache-inl.h.
Referenced by wangle::LRUInMemoryCache< K, V, M >::LRUInMemoryCache().
bool wangle::LRUInMemoryCache< K, V, M >::remove | ( | const K & | key | ) |
Definition at line 42 of file LRUInMemoryCache-inl.h.
size_t wangle::LRUInMemoryCache< K, V, M >::size | ( | ) | const |
Definition at line 53 of file LRUInMemoryCache-inl.h.
Referenced by wangle::LRUInMemoryCache< K, V, M >::LRUInMemoryCache().
|
private |
Definition at line 76 of file LRUInMemoryCache.h.
|
mutableprivate |
Definition at line 80 of file LRUInMemoryCache.h.
|
private |
Definition at line 78 of file LRUInMemoryCache.h.
Referenced by wangle::LRUInMemoryCache< K, V, M >::incrementVersion().