]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/CacheDigest.h
9fc266bb8ac7e8844cbff6abac9c6324a72dcd12
2 * Copyright (C) 1996-2018 The Squid Software Foundation and contributors
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.
9 /* DEBUG: section 70 Cache Digest */
11 #ifndef SQUID_CACHEDIGEST_H_
12 #define SQUID_CACHEDIGEST_H_
14 #include "mem/forward.h"
15 #include "store_key_md5.h"
17 class CacheDigestGuessStats
;
22 MEMPROXY_CLASS(CacheDigest
);
24 CacheDigest(uint64_t capacity
, uint8_t bpe
);
27 // NP: only used by broken unit-test
28 /// produce a new identical copy of the digest object
29 CacheDigest
*clone() const;
31 /// reset the digest mask and counters
34 /// changes mask size to fit newCapacity, resets bits to 0
35 void updateCapacity(uint64_t newCapacity
);
37 void add(const cache_key
* key
);
38 void remove(const cache_key
* key
);
40 /// \returns true if the key belongs to the digest
41 bool contains(const cache_key
* key
) const;
43 /// percentage of mask bits which are used
44 double usedMaskPercent() const;
46 /// calculate the size of mask required to digest up to
47 /// a specified capacity and bitsize.
48 static uint32_t CalcMaskSize(uint64_t cap
, uint8_t bpe
);
51 void init(uint64_t newCapacity
);
54 /* public, read-only */
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 */
63 void cacheDigestGuessStatsUpdate(CacheDigestGuessStats
* stats
, int real_hit
, int guess_hit
);
64 void cacheDigestGuessStatsReport(const CacheDigestGuessStats
* stats
, StoreEntry
* sentry
, const char *label
);
65 void cacheDigestReport(CacheDigest
* cd
, const char *label
, StoreEntry
* e
);
67 #endif /* SQUID_CACHEDIGEST_H_ */