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_SRC_CACHEDIGEST_H
12 #define SQUID_SRC_CACHEDIGEST_H
13 
14 #include "mem/forward.h"
15 #include "store_key_md5.h"
16 
18 class StoreEntry;
19 
21 {
23 public:
24  CacheDigest(uint64_t capacity, uint8_t bpe);
25  ~CacheDigest();
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 
50 private:
51  void init(uint64_t newCapacity);
52 
53 public:
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 
63 void cacheDigestGuessStatsUpdate(CacheDigestGuessStats * stats, int real_hit, int guess_hit);
64 void cacheDigestGuessStatsReport(const CacheDigestGuessStats * stats, StoreEntry * sentry, const SBuf &label);
65 void cacheDigestReport(CacheDigest * cd, const SBuf &label, StoreEntry * e);
66 
67 #endif /* SQUID_SRC_CACHEDIGEST_H */
68 
void cacheDigestGuessStatsReport(const CacheDigestGuessStats *stats, StoreEntry *sentry, const SBuf &label)
Definition: CacheDigest.cc:209
double usedMaskPercent() const
percentage of mask bits which are used
Definition: CacheDigest.cc:183
unsigned char cache_key
Store key.
Definition: forward.h:29
uint64_t capacity
Definition: CacheDigest.h:57
void clear()
reset the digest mask and counters
Definition: CacheDigest.cc:79
int8_t bits_per_entry
Definition: CacheDigest.h:60
Definition: SBuf.h:93
void updateCapacity(uint64_t newCapacity)
changes mask size to fit newCapacity, resets bits to 0
Definition: CacheDigest.cc:86
CacheDigest * clone() const
produce a new identical copy of the digest object
Definition: CacheDigest.cc:68
void remove(const cache_key *key)
Definition: CacheDigest.cc:140
MEMPROXY_CLASS(CacheDigest)
static uint32_t CalcMaskSize(uint64_t cap, uint8_t bpe)
Definition: CacheDigest.cc:273
char * mask
Definition: CacheDigest.h:58
uint64_t del_count
Definition: CacheDigest.h:56
void cacheDigestReport(CacheDigest *cd, const SBuf &label, StoreEntry *e)
Definition: CacheDigest.cc:245
CacheDigest(uint64_t capacity, uint8_t bpe)
Definition: CacheDigest.cc:50
void add(const cache_key *key)
Definition: CacheDigest.cc:107
bool contains(const cache_key *key) const
Definition: CacheDigest.cc:93
void init(uint64_t newCapacity)
Definition: CacheDigest.cc:38
uint32_t mask_size
Definition: CacheDigest.h:59
uint64_t count
Definition: CacheDigest.h:55
void cacheDigestGuessStatsUpdate(CacheDigestGuessStats *stats, int real_hit, int guess_hit)
Definition: CacheDigest.cc:191

 

Introduction

Documentation

Support

Miscellaneous