CacheDigest.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2018 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 
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 char *label);
65 void cacheDigestReport(CacheDigest * cd, const char *label, StoreEntry * e);
66 
67 #endif /* SQUID_CACHEDIGEST_H_ */
68 
uint64_t count
Definition: CacheDigest.h:55
unsigned char cache_key
Store key.
Definition: forward.h:29
MEMPROXY_CLASS(CacheDigest)
class Ping::pingStats_ stats
void init(uint64_t newCapacity)
Definition: CacheDigest.cc:38
void cacheDigestGuessStatsUpdate(CacheDigestGuessStats *stats, int real_hit, int guess_hit)
Definition: CacheDigest.cc:202
static uint32_t CalcMaskSize(uint64_t cap, uint8_t bpe)
Definition: CacheDigest.cc:284
int8_t bits_per_entry
Definition: CacheDigest.h:60
CacheDigest(uint64_t capacity, uint8_t bpe)
Definition: CacheDigest.cc:50
void add(const cache_key *key)
Definition: CacheDigest.cc:107
uint32_t mask_size
Definition: CacheDigest.h:59
CacheDigest * clone() const
produce a new identical copy of the digest object
Definition: CacheDigest.cc:68
void updateCapacity(uint64_t newCapacity)
changes mask size to fit newCapacity, resets bits to 0
Definition: CacheDigest.cc:86
void cacheDigestGuessStatsReport(const CacheDigestGuessStats *stats, StoreEntry *sentry, const char *label)
Definition: CacheDigest.cc:220
void cacheDigestReport(CacheDigest *cd, const char *label, StoreEntry *e)
Definition: CacheDigest.cc:256
bool contains(const cache_key *key) const
Definition: CacheDigest.cc:93
uint64_t del_count
Definition: CacheDigest.h:56
void clear()
reset the digest mask and counters
Definition: CacheDigest.cc:79
double usedMaskPercent() const
percentage of mask bits which are used
Definition: CacheDigest.cc:194
uint64_t capacity
Definition: CacheDigest.h:57
char * mask
Definition: CacheDigest.h:58

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors