proxygen
|
#include <SlidingBloomReplayCache.h>
Public Types | |
using | CellType = uint64_t |
using | HashFunction = std::function< CellType(const unsigned char *, size_t)> |
Public Member Functions | |
SlidingBloomReplayCache (int64_t ttlInSeconds, size_t requestsPerSecond, double acceptableFPR, folly::EventBase *evb) | |
~SlidingBloomReplayCache () override=default | |
void | set (folly::ByteRange query) |
bool | test (folly::ByteRange query) const |
bool | testAndSet (folly::ByteRange query) |
folly::Future< ReplayCacheResult > | check (folly::ByteRange) override |
Public Member Functions inherited from fizz::server::ReplayCache | |
virtual | ~ReplayCache ()=default |
Private Member Functions | |
void | clearBucket (size_t bucket) |
void | clear () |
void | timeoutExpired () noexceptoverride |
Private Member Functions inherited from folly::AsyncTimeout | |
AsyncTimeout (TimeoutManager *timeoutManager) | |
AsyncTimeout (EventBase *eventBase) | |
AsyncTimeout (TimeoutManager *timeoutManager, InternalEnum internal) | |
AsyncTimeout (EventBase *eventBase, InternalEnum internal) | |
AsyncTimeout () | |
virtual | ~AsyncTimeout () |
bool | scheduleTimeout (uint32_t milliseconds) |
bool | scheduleTimeout (TimeoutManager::timeout_type timeout) |
void | cancelTimeout () |
bool | isScheduled () const |
void | attachTimeoutManager (TimeoutManager *timeoutManager, InternalEnum internal=InternalEnum::NORMAL) |
void | attachEventBase (EventBase *eventBase, InternalEnum internal=InternalEnum::NORMAL) |
void | detachTimeoutManager () |
void | detachEventBase () |
const TimeoutManager * | getTimeoutManager () |
struct event * | getEvent () |
Private Attributes | |
std::chrono::milliseconds | bucketWidthInMs_ |
size_t | bitSize_ |
size_t | currentBucket_ |
std::unique_ptr< CellType[]> | bitBuf_ |
std::vector< HashFunction > | hashers_ |
Additional Inherited Members | |
Private Types inherited from folly::AsyncTimeout | |
typedef TimeoutManager::InternalEnum | InternalEnum |
Static Private Member Functions inherited from folly::AsyncTimeout | |
template<typename TCallback > | |
static std::unique_ptr< AsyncTimeout > | make (TimeoutManager &manager, TCallback &&callback) |
template<typename TCallback > | |
static std::unique_ptr< AsyncTimeout > | schedule (TimeoutManager::timeout_type timeout, TimeoutManager &manager, TCallback &&callback) |
Definition at line 23 of file SlidingBloomReplayCache.h.
Definition at line 29 of file SlidingBloomReplayCache.h.
using fizz::server::SlidingBloomReplayCache::HashFunction = std::function<CellType(const unsigned char*, size_t)> |
Definition at line 30 of file SlidingBloomReplayCache.h.
fizz::server::SlidingBloomReplayCache::SlidingBloomReplayCache | ( | int64_t | ttlInSeconds, |
size_t | requestsPerSecond, | ||
double | acceptableFPR, | ||
folly::EventBase * | evb | ||
) |
Definition at line 56 of file SlidingBloomReplayCache.cpp.
References bitBuf_, bitSize_, bucketWidthInMs_, currentBucket_, hashers_, i, fizz::server::kBucketCount, fizz::server::kHashCount, folly::AsyncTimeout::scheduleTimeout(), seed, and uint64_t.
|
overridedefault |
|
overridevirtual |
Implements fizz::server::ReplayCache.
Definition at line 139 of file SlidingBloomReplayCache.cpp.
References fizz::server::MaybeReplay, folly::gen::move, fizz::server::NotReplay, and testAndSet().
|
private |
Definition at line 155 of file SlidingBloomReplayCache.cpp.
References clearBucket(), and currentBucket_.
Referenced by timeoutExpired().
|
private |
Definition at line 145 of file SlidingBloomReplayCache.cpp.
References bitBuf_, bitSize_, currentBucket_, and i.
Referenced by clear().
void fizz::server::SlidingBloomReplayCache::set | ( | folly::ByteRange | query | ) |
Definition at line 103 of file SlidingBloomReplayCache.cpp.
References bitBuf_, bitSize_, currentBucket_, folly::Range< Iter >::data(), hashers_, and folly::Range< Iter >::size().
Referenced by fizz::server::test::TEST().
bool fizz::server::SlidingBloomReplayCache::test | ( | folly::ByteRange | query | ) | const |
Definition at line 113 of file SlidingBloomReplayCache.cpp.
References bitBuf_, bitSize_, folly::Range< Iter >::data(), hashers_, max, and folly::Range< Iter >::size().
Referenced by fizz::server::test::TEST().
bool fizz::server::SlidingBloomReplayCache::testAndSet | ( | folly::ByteRange | query | ) |
Definition at line 125 of file SlidingBloomReplayCache.cpp.
References bitBuf_, bitSize_, currentBucket_, folly::Range< Iter >::data(), hashers_, max, and folly::Range< Iter >::size().
Referenced by check(), and fizz::server::test::TEST().
|
overrideprivatevirtualnoexcept |
timeoutExpired() is invoked when the timeout period has expired.
Implements folly::AsyncTimeout.
Definition at line 163 of file SlidingBloomReplayCache.cpp.
References bucketWidthInMs_, clear(), and folly::AsyncTimeout::scheduleTimeout().
|
private |
Definition at line 65 of file SlidingBloomReplayCache.h.
Referenced by clearBucket(), set(), SlidingBloomReplayCache(), test(), and testAndSet().
|
private |
Definition at line 60 of file SlidingBloomReplayCache.h.
Referenced by clearBucket(), set(), SlidingBloomReplayCache(), test(), and testAndSet().
|
private |
Definition at line 59 of file SlidingBloomReplayCache.h.
Referenced by SlidingBloomReplayCache(), and timeoutExpired().
|
private |
Definition at line 62 of file SlidingBloomReplayCache.h.
Referenced by clear(), clearBucket(), set(), SlidingBloomReplayCache(), and testAndSet().
|
private |
Definition at line 67 of file SlidingBloomReplayCache.h.
Referenced by set(), SlidingBloomReplayCache(), test(), and testAndSet().