]> git.ipfire.org Git - thirdparty/squid.git/blame - src/RefreshPattern.h
Source Format Enforcement (#532)
[thirdparty/squid.git] / src / RefreshPattern.h
CommitLineData
8d9a8184 1/*
77b1029d 2 * Copyright (C) 1996-2020 The Squid Software Foundation and contributors
8d9a8184 3 *
bbc27441
AJ
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.
8d9a8184
FC
7 */
8
bbc27441
AJ
9#ifndef SQUID_REFRESHPATTERN_H_
10#define SQUID_REFRESHPATTERN_H_
11
95b8eae2 12#include "base/RegexPattern.h"
09a86349 13
95b8eae2 14/// a representation of a refresh pattern.
1b2f0924
FC
15class RefreshPattern
16{
95b8eae2
AJ
17 MEMPROXY_CLASS(RefreshPattern);
18
8d9a8184 19public:
95b8eae2
AJ
20
21 /*
22 * Defaults:
23 * MIN NONE
24 * PCT 20%
25 * MAX 3 days
26 */
27#define REFRESH_DEFAULT_MAX static_cast<time_t>(259200)
28
29 RefreshPattern(const char *aPattern, const decltype(RegexPattern::flags) &reFlags) :
30 pattern(reFlags, aPattern),
31 min(0), pct(0.20), max(REFRESH_DEFAULT_MAX),
32 next(NULL),
33 max_stale(0)
34 {
35 memset(&flags, 0, sizeof(flags));
36 }
37
38 ~RefreshPattern() {
39 while (RefreshPattern *t = next) {
40 next = t->next;
41 t->next = nullptr;
42 delete t;
43 }
44 }
45 // ~RefreshPattern() default destructor is fine
46
47 RegexPattern pattern;
8d9a8184
FC
48 time_t min;
49 double pct;
50 time_t max;
51 RefreshPattern *next;
52
53 struct {
be4d35dc
FC
54 bool refresh_ims;
55 bool store_stale;
8d9a8184 56#if USE_HTTP_VIOLATIONS
be4d35dc
FC
57 bool override_expire;
58 bool override_lastmod;
59 bool reload_into_ims;
60 bool ignore_reload;
61 bool ignore_no_store;
be4d35dc 62 bool ignore_private;
8d9a8184
FC
63#endif
64 } flags;
65 int max_stale;
a5ea7751
AJ
66
67 // statistics about how many matches this pattern has had
68 mutable struct stats_ {
95b8eae2
AJ
69 stats_() : matchTests(0), matchCount(0) {}
70
a5ea7751
AJ
71 uint64_t matchTests;
72 uint64_t matchCount;
73 // TODO: some stats to indicate how useful/less the flags are would be nice.
74 } stats;
8d9a8184
FC
75};
76
77#endif /* SQUID_REFRESHPATTERN_H_ */
f53969cc 78