proxygen
fizz::client::SynchronizedLruPskCache Class Reference

#include <SynchronizedLruPskCache.h>

Inheritance diagram for fizz::client::SynchronizedLruPskCache:
fizz::client::PskCache

Public Types

using EvictingPskMap = folly::EvictingCacheMap< std::string, CachedPsk >
 

Public Member Functions

 ~SynchronizedLruPskCache () override=default
 
 SynchronizedLruPskCache (uint64_t mapMax)
 
folly::Optional< CachedPskgetPsk (const std::string &identity) override
 
void putPsk (const std::string &identity, CachedPsk psk) override
 
void removePsk (const std::string &identity) override
 
- Public Member Functions inherited from fizz::client::PskCache
virtual ~PskCache ()=default
 

Private Attributes

folly::Synchronized< EvictingPskMapcache_
 

Detailed Description

PSK cache that provides synchronization and caps the number of PSKs stored internally. When the limit is reached, the least recently used PSK is evicted.

Definition at line 23 of file SynchronizedLruPskCache.h.

Member Typedef Documentation

Constructor & Destructor Documentation

fizz::client::SynchronizedLruPskCache::~SynchronizedLruPskCache ( )
overridedefault
fizz::client::SynchronizedLruPskCache::SynchronizedLruPskCache ( uint64_t  mapMax)
explicit

Definition at line 14 of file SynchronizedLruPskCache.cpp.

15  : cache_(EvictingPskMap(mapMax)) {}
folly::Synchronized< EvictingPskMap > cache_
folly::EvictingCacheMap< std::string, CachedPsk > EvictingPskMap

Member Function Documentation

folly::Optional< CachedPsk > fizz::client::SynchronizedLruPskCache::getPsk ( const std::string identity)
overridevirtual

Retrieve a PSK for the specified identity.

Implements fizz::client::PskCache.

Definition at line 17 of file SynchronizedLruPskCache.cpp.

References cache_, and folly::none.

18  {
19  auto cacheMap = cache_.wlock();
20  auto result = cacheMap->find(identity);
21  if (result != cacheMap->end()) {
22  return result->second;
23  } else {
24  return folly::none;
25  }
26 }
folly::Synchronized< EvictingPskMap > cache_
constexpr None none
Definition: Optional.h:87
void fizz::client::SynchronizedLruPskCache::putPsk ( const std::string identity,
CachedPsk   
)
overridevirtual

Add a new PSK for identity to the cache.

Implements fizz::client::PskCache.

Definition at line 28 of file SynchronizedLruPskCache.cpp.

References cache_, and folly::gen::move.

30  {
31  auto cacheMap = cache_.wlock();
32  cacheMap->set(identity, std::move(psk));
33 }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
folly::Synchronized< EvictingPskMap > cache_
void fizz::client::SynchronizedLruPskCache::removePsk ( const std::string identity)
overridevirtual

Remove any PSKs associated with identity from the cache.

Implements fizz::client::PskCache.

Definition at line 35 of file SynchronizedLruPskCache.cpp.

References cache_.

35  {
36  auto cacheMap = cache_.wlock();
37  cacheMap->erase(identity);
38 }
folly::Synchronized< EvictingPskMap > cache_

Member Data Documentation

folly::Synchronized<EvictingPskMap> fizz::client::SynchronizedLruPskCache::cache_
private

Definition at line 36 of file SynchronizedLruPskCache.h.

Referenced by getPsk(), putPsk(), and removePsk().


The documentation for this class was generated from the following files: