]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/RefreshPattern.h
5de52b9c4861370f32689de2f702899d94640336
2 * Copyright (C) 1996-2022 The Squid Software Foundation and contributors
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.
9 #ifndef SQUID_REFRESHPATTERN_H_
10 #define SQUID_REFRESHPATTERN_H_
12 #include "base/RegexPattern.h"
16 /// a representation of a refresh pattern.
19 MEMPROXY_CLASS(RefreshPattern
);
29 #define REFRESH_DEFAULT_MAX static_cast<time_t>(259200)
31 using RegexPointer
= std::unique_ptr
<RegexPattern
>;
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
),
39 regex_(std::move(aRegex
))
41 memset(&flags
, 0, sizeof(flags
));
45 while (RefreshPattern
*t
= next
) {
60 #if USE_HTTP_VIOLATIONS
62 bool override_lastmod
;
71 // statistics about how many matches this pattern has had
72 mutable struct stats_
{
73 stats_() : matchTests(0), matchCount(0) {}
77 // TODO: some stats to indicate how useful/less the flags are would be nice.
80 /// reports configuration excluding trailing options
81 void printHead(std::ostream
&) const;
83 /// reports the configured pattern or a fake pattern of the implicit rule
84 void printPattern(std::ostream
&os
) const;
86 // TODO: Refactor external refresh_pattern rules iterators to make private.
87 /// configured regex; do not use except when iterating configured rules
88 const RegexPattern
®ex() const;
91 /// configured regex or, for the implicit refresh_pattern rule, nil
96 operator <<(std::ostream
&os
, const RefreshPattern
&r
)
102 #endif /* SQUID_REFRESHPATTERN_H_ */