RefreshPattern.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 #ifndef SQUID_SRC_REFRESHPATTERN_H
10 #define SQUID_SRC_REFRESHPATTERN_H
11 
12 #include "base/RegexPattern.h"
13 
14 #include <memory>
15 
18 {
20 
21 public:
22 
23  /*
24  * Defaults:
25  * MIN NONE
26  * PCT 20%
27  * MAX 3 days
28  */
29 #define REFRESH_DEFAULT_MAX static_cast<time_t>(259200)
30 
31  using RegexPointer = std::unique_ptr<RegexPattern>;
32 
33  // If given a regex, becomes its owner, creating an explicit refresh_pattern
34  // rule. Otherwise, creates an implicit/default refresh_pattern rule.
35  explicit RefreshPattern(RegexPointer aRegex):
36  min(0), pct(0.20), max(REFRESH_DEFAULT_MAX),
37  next(nullptr),
38  max_stale(-1),
39  regex_(std::move(aRegex))
40  {
41  memset(&flags, 0, sizeof(flags));
42  }
43 
45  while (RefreshPattern *t = next) {
46  next = t->next;
47  t->next = nullptr;
48  delete t;
49  }
50  }
51 
52  time_t min;
53  double pct;
54  time_t max;
56 
57  struct {
60 #if USE_HTTP_VIOLATIONS
67 #endif
68  } flags;
69  int max_stale;
70 
71  // statistics about how many matches this pattern has had
72  mutable struct stats_ {
74 
75  uint64_t matchTests;
76  uint64_t matchCount;
77  // TODO: some stats to indicate how useful/less the flags are would be nice.
78  } stats;
79 
81  void printHead(std::ostream &) const;
82 
84  void printPattern(std::ostream &os) const;
85 
86  // TODO: Refactor external refresh_pattern rules iterators to make private.
88  const RegexPattern &regex() const;
89 
90 private:
93 };
94 
95 inline std::ostream &
96 operator <<(std::ostream &os, const RefreshPattern &r)
97 {
98  r.printHead(os);
99  return os;
100 }
101 
102 #endif /* SQUID_SRC_REFRESHPATTERN_H */
103 
struct RefreshPattern::stats_ stats
std::unique_ptr< RegexPattern > RegexPointer
a representation of a refresh pattern.
std::ostream & operator<<(std::ostream &os, const RefreshPattern &r)
struct RefreshPattern::@80 flags
MEMPROXY_CLASS(RefreshPattern)
RefreshPattern(RegexPointer aRegex)
#define REFRESH_DEFAULT_MAX
const RegexPattern & regex() const
configured regex; do not use except when iterating configured rules
Definition: refresh.cc:727
RegexPointer regex_
configured regex or, for the implicit refresh_pattern rule, nil
void printPattern(std::ostream &os) const
reports the configured pattern or a fake pattern of the implicit rule
Definition: refresh.cc:734
RefreshPattern * next
void printHead(std::ostream &) const
reports configuration excluding trailing options
Definition: refresh.cc:743

 

Introduction

Documentation

Support

Miscellaneous