CacheDigest.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 1996-2023 The Squid Software Foundation and contributors
3 *
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.
7 */
8
9/* DEBUG: section 70 Cache Digest */
10
11#ifndef SQUID_CACHEDIGEST_H_
12#define SQUID_CACHEDIGEST_H_
13
14#include "mem/forward.h"
15#include "store_key_md5.h"
16
18class StoreEntry;
19
21{
23public:
24 CacheDigest(uint64_t capacity, uint8_t bpe);
26
27 // NP: only used by broken unit-test
29 CacheDigest *clone() const;
30
32 void clear();
33
35 void updateCapacity(uint64_t newCapacity);
36
37 void add(const cache_key * key);
38 void remove(const cache_key * key);
39
41 bool contains(const cache_key * key) const;
42
44 double usedMaskPercent() const;
45
48 static uint32_t CalcMaskSize(uint64_t cap, uint8_t bpe);
49
50private:
51 void init(uint64_t newCapacity);
52
53public:
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 */
61};
62
63void cacheDigestGuessStatsUpdate(CacheDigestGuessStats * stats, int real_hit, int guess_hit);
64void cacheDigestGuessStatsReport(const CacheDigestGuessStats * stats, StoreEntry * sentry, const SBuf &label);
65void cacheDigestReport(CacheDigest * cd, const SBuf &label, StoreEntry * e);
66
67#endif /* SQUID_CACHEDIGEST_H_ */
68
void cacheDigestGuessStatsReport(const CacheDigestGuessStats *stats, StoreEntry *sentry, const SBuf &label)
Definition: CacheDigest.cc:209
void cacheDigestGuessStatsUpdate(CacheDigestGuessStats *stats, int real_hit, int guess_hit)
Definition: CacheDigest.cc:191
void cacheDigestReport(CacheDigest *cd, const SBuf &label, StoreEntry *e)
Definition: CacheDigest.cc:245
void updateCapacity(uint64_t newCapacity)
changes mask size to fit newCapacity, resets bits to 0
Definition: CacheDigest.cc:86
char * mask
Definition: CacheDigest.h:58
double usedMaskPercent() const
percentage of mask bits which are used
Definition: CacheDigest.cc:183
static uint32_t CalcMaskSize(uint64_t cap, uint8_t bpe)
Definition: CacheDigest.cc:273
uint64_t del_count
Definition: CacheDigest.h:56
CacheDigest(uint64_t capacity, uint8_t bpe)
Definition: CacheDigest.cc:50
uint64_t count
Definition: CacheDigest.h:55
uint32_t mask_size
Definition: CacheDigest.h:59
void init(uint64_t newCapacity)
Definition: CacheDigest.cc:38
void add(const cache_key *key)
Definition: CacheDigest.cc:107
CacheDigest * clone() const
produce a new identical copy of the digest object
Definition: CacheDigest.cc:68
uint64_t capacity
Definition: CacheDigest.h:57
int8_t bits_per_entry
Definition: CacheDigest.h:60
bool contains(const cache_key *key) const
Definition: CacheDigest.cc:93
void clear()
reset the digest mask and counters
Definition: CacheDigest.cc:79
MEMPROXY_CLASS(CacheDigest)
void remove(const cache_key *key)
Definition: CacheDigest.cc:140
Definition: SBuf.h:94
class Ping::pingStats_ stats
unsigned char cache_key
Store key.
Definition: forward.h:29

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors