]>
Commit | Line | Data |
---|---|---|
fc54b8d2 | 1 | /* |
b8ae064d | 2 | * Copyright (C) 1996-2023 The Squid Software Foundation and contributors |
7bc5d260 | 3 | * |
bbc27441 AJ |
4 | * Squid software is distributed under GPLv2+ license and includes |
5 | * contributions from numerous individuals and organizations. | |
6 | * Please see the COPYING and CONTRIBUTORS files for details. | |
fc54b8d2 FC |
7 | */ |
8 | ||
bbc27441 AJ |
9 | /* DEBUG: section 70 Cache Digest */ |
10 | ||
ff9d9458 FC |
11 | #ifndef SQUID_SRC_CACHEDIGEST_H |
12 | #define SQUID_SRC_CACHEDIGEST_H | |
bbc27441 | 13 | |
e04fc9d3 | 14 | #include "mem/forward.h" |
e1ba42a4 | 15 | #include "store_key_md5.h" |
d8403776 | 16 | |
fc54b8d2 FC |
17 | class CacheDigestGuessStats; |
18 | class StoreEntry; | |
d8403776 | 19 | |
1b2f0924 FC |
20 | class CacheDigest |
21 | { | |
e04fc9d3 AJ |
22 | MEMPROXY_CLASS(CacheDigest); |
23 | public: | |
831e953c | 24 | CacheDigest(uint64_t capacity, uint8_t bpe); |
a901d0b4 | 25 | ~CacheDigest(); |
e04fc9d3 | 26 | |
fab3d38b AJ |
27 | // NP: only used by broken unit-test |
28 | /// produce a new identical copy of the digest object | |
29 | CacheDigest *clone() const; | |
30 | ||
28faff32 AJ |
31 | /// reset the digest mask and counters |
32 | void clear(); | |
33 | ||
7daad00c | 34 | /// changes mask size to fit newCapacity, resets bits to 0 |
831e953c | 35 | void updateCapacity(uint64_t newCapacity); |
7daad00c | 36 | |
fbba122c AJ |
37 | void add(const cache_key * key); |
38 | void remove(const cache_key * key); | |
39 | ||
5bc5e81f | 40 | /// \returns true if the key belongs to the digest |
6fc4e508 | 41 | bool contains(const cache_key * key) const; |
5bc5e81f | 42 | |
6fbd1d41 AJ |
43 | /// percentage of mask bits which are used |
44 | double usedMaskPercent() const; | |
45 | ||
5bc5e81f AJ |
46 | /// calculate the size of mask required to digest up to |
47 | /// a specified capacity and bitsize. | |
831e953c | 48 | static uint32_t CalcMaskSize(uint64_t cap, uint8_t bpe); |
5bc5e81f | 49 | |
afffcaab | 50 | private: |
831e953c | 51 | void init(uint64_t newCapacity); |
afffcaab | 52 | |
d8403776 FC |
53 | public: |
54 | /* public, read-only */ | |
831e953c AJ |
55 | uint64_t count; /* number of digested entries */ |
56 | uint64_t del_count; /* number of deletions performed so far */ | |
57 | uint64_t capacity; /* expected maximum for .count, not a hard limit */ | |
58 | char *mask; /* bit mask */ | |
59 | uint32_t mask_size; /* mask size in bytes */ | |
60 | int8_t bits_per_entry; /* number of bits allocated for each entry from capacity */ | |
d8403776 | 61 | }; |
fc54b8d2 | 62 | |
001d55dc | 63 | void cacheDigestGuessStatsUpdate(CacheDigestGuessStats * stats, int real_hit, int guess_hit); |
0e3b8c9f AJ |
64 | void cacheDigestGuessStatsReport(const CacheDigestGuessStats * stats, StoreEntry * sentry, const SBuf &label); |
65 | void cacheDigestReport(CacheDigest * cd, const SBuf &label, StoreEntry * e); | |
fc54b8d2 | 66 | |
ff9d9458 | 67 | #endif /* SQUID_SRC_CACHEDIGEST_H */ |
f53969cc | 68 |