12 #include <sys/types.h> 17 #include <boost/chrono/duration.hpp> 36 "Bucket count greater than cell bit count");
56 SlidingBloomReplayCache::SlidingBloomReplayCache(
58 size_t requestsPerSecond,
61 :
folly::AsyncTimeout(evb) {
62 if (acceptableFPR <= 0.0 || acceptableFPR >= 1.0) {
63 throw std::runtime_error(
"false positive rate must lie between 0 and 1");
67 double ttlDouble = ttlInSecs;
68 double rpsDouble = requestsPerSecond;
71 double dividend = -hashCountDouble * rpsDouble * ttlDouble;
72 double root = pow(acceptableFPR, 1.0 / hashCountDouble);
73 double divisor = bucketCountDouble * log(1.0 - root);
75 VLOG(8) <<
"Initializing with bitSize = " <<
bitSize_;
78 std::chrono::milliseconds(((ttlInSecs * 1000) / kBucketCount) + 1);
90 const unsigned char* buf,
size_t len) ->
uint64_t {
91 return SpookyHashV2::Hash64((
const void*)buf, len,
seed);
99 VLOG(8) <<
"Started replay cache without reaping";
146 VLOG(8) <<
"Clearing bit " << bucket <<
", current bucket is " static const int kBitsPerByte
void clearBucket(size_t bucket)
bool testAndSet(folly::ByteRange query)
bool test(folly::ByteRange query) const
constexpr detail::Map< Move > move
constexpr size_type size() const
static const unsigned int kBucketCount
std::vector< HashFunction > hashers_
—— Concurrent Priority Queue Implementation ——
requires E e noexcept(noexcept(s.error(std::move(e))))
std::unique_ptr< CellType[]> bitBuf_
void set(folly::ByteRange query)
void timeoutExpired() noexceptoverride
constexpr Iter data() const
folly::Future< ReplayCacheResult > check(folly::ByteRange) override
bool scheduleTimeout(uint32_t milliseconds)
std::chrono::milliseconds bucketWidthInMs_
static const unsigned int kHashCount