]> git.ipfire.org Git - thirdparty/squid.git/blame - src/store/Controller.h
Collapse internal revalidation requests (SMP-unaware caches).
[thirdparty/squid.git] / src / store / Controller.h
CommitLineData
2745fea5 1/*
ef57eb7b 2 * Copyright (C) 1996-2016 The Squid Software Foundation and contributors
2745fea5
AR
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_STORE_CONTROLLER_H
10#define SQUID_STORE_CONTROLLER_H
11
12#include "store/Storage.h"
13
14class MemObject;
15class RequestFlags;
16class HttpRequestMethod;
17
18namespace Store {
19
20/// Public Store interface. Coordinates the work of memory/disk/transient stores
21/// and hides their individual existence/differences from the callers.
22class Controller: public Storage
23{
24public:
25 Controller();
26 virtual ~Controller() override;
27
28 /* Storage API */
29 virtual void create() override;
30 virtual void init() override;
31 virtual StoreEntry *get(const cache_key *) override;
32 virtual uint64_t maxSize() const override;
33 virtual uint64_t minSize() const override;
34 virtual uint64_t currentSize() const override;
35 virtual uint64_t currentCount() const override;
36 virtual int64_t maxObjectSize() const override;
37 virtual void getStats(StoreInfoStats &stats) const override;
38 virtual void stat(StoreEntry &) const override;
39 virtual void sync() override;
40 virtual void maintain() override;
41 virtual void markForUnlink(StoreEntry &) override;
42 virtual void unlink(StoreEntry &) override;
43 virtual int callback() override;
1a210de4 44 virtual bool smpAware() const override;
2745fea5 45
5ca027f0
AR
46 /// Additional unknown-size entry bytes required by Store in order to
47 /// reduce the risk of selecting the wrong disk cache for the growing entry.
48 int64_t accumulateMore(StoreEntry &) const;
49
50 /// slowly calculate (and cache) hi/lo watermarks and similar limits
51 void updateLimits();
52
2745fea5
AR
53 /// called when the entry is no longer needed by any transaction
54 void handleIdleEntry(StoreEntry &);
55
56 /// called to get rid of no longer needed entry data in RAM, if any
57 void memoryOut(StoreEntry &, const bool preserveSwappable);
58
abf396ec
AR
59 /// update old entry metadata and HTTP headers using a newer entry
60 void updateOnNotModified(StoreEntry *old, const StoreEntry &newer);
61
2745fea5
AR
62 /// makes the entry available for collapsing future requests
63 void allowCollapsing(StoreEntry *, const RequestFlags &, const HttpRequestMethod &);
64
65 /// marks the entry completed for collapsed requests
66 void transientsCompleteWriting(StoreEntry &);
67
68 /// Update local intransit entry after changes made by appending worker.
69 void syncCollapsed(const sfileno);
70
71 /// calls Root().transients->abandon() if transients are tracked
72 void transientsAbandon(StoreEntry &);
73
74 /// number of the transient entry readers some time ago
75 int transientReaders(const StoreEntry &) const;
76
77 /// disassociates the entry from the intransit table
78 void transientsDisconnect(MemObject &);
79
80 /// removes the entry from the memory cache
81 void memoryUnlink(StoreEntry &);
82
83 /// disassociates the entry from the memory cache, preserving cached data
84 void memoryDisconnect(StoreEntry &);
85
86 /// \returns an iterator for all Store entries
87 StoreSearch *search();
88
89 /// the number of cache_dirs being rebuilt; TODO: move to Disks::Rebuilding
90 static int store_dirs_rebuilding;
91
92private:
93 /// update reference counters of the recently touched entry
94 void referenceBusy(StoreEntry &e);
95 /// dereference() an idle entry and return true if the entry should be deleted
96 bool dereferenceIdle(StoreEntry &, bool wantsLocalMemory);
97
98 StoreEntry *find(const cache_key *key);
99 bool keepForLocalMemoryCache(StoreEntry &e) const;
100 bool anchorCollapsed(StoreEntry &, bool &inSync);
101
102 Disks *swapDir; ///< summary view of all disk caches
103 Memory *memStore; ///< memory cache
104
105 /// A shared table of public store entries that do not know whether they
106 /// will belong to a memory cache, a disk cache, or will be uncachable
107 /// when the response header comes. Used for SMP collapsed forwarding.
108 Transients *transients;
109};
110
111/// safely access controller singleton
112extern Controller &Root();
113
114/// initialize the storage module; a custom root is used by unit tests only
115extern void Init(Controller *root = nullptr);
116
117/// undo Init()
118extern void FreeMemory();
119
120} // namespace Store
121
122#endif /* SQUID_STORE_CONTROLLER_H */
7d84d4ca 123