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_REFRESHPATTERN_H_
10#define SQUID_REFRESHPATTERN_H_
11
12#include "base/RegexPattern.h"
13
14#include <memory>
15
18{
20
21public:
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(0),
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
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.
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
90private:
93};
94
95inline std::ostream &
96operator <<(std::ostream &os, const RefreshPattern &r)
97{
98 r.printHead(os);
99 return os;
100}
101
102#endif /* SQUID_REFRESHPATTERN_H_ */
103
#define REFRESH_DEFAULT_MAX
std::ostream & operator<<(std::ostream &os, const RefreshPattern &r)
a representation of a refresh pattern.
struct RefreshPattern::@89 flags
RefreshPattern(RegexPointer aRegex)
struct RefreshPattern::stats_ stats
RefreshPattern * next
MEMPROXY_CLASS(RefreshPattern)
void printPattern(std::ostream &os) const
reports the configured pattern or a fake pattern of the implicit rule
Definition: refresh.cc:728
const RegexPattern & regex() const
configured regex; do not use except when iterating configured rules
Definition: refresh.cc:721
RegexPointer regex_
configured regex or, for the implicit refresh_pattern rule, nil
void printHead(std::ostream &) const
reports configuration excluding trailing options
Definition: refresh.cc:737
std::unique_ptr< RegexPattern > RegexPointer
STL namespace.

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors