]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/store/Controller.h
2 * Copyright (C) 1996-2018 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_STORE_CONTROLLER_H
10 #define SQUID_STORE_CONTROLLER_H
12 #include "store/Storage.h"
16 class HttpRequestMethod
;
20 /// Public Store interface. Coordinates the work of memory/disk/transient stores
21 /// and hides their individual existence/differences from the callers.
22 class Controller
: public Storage
26 virtual ~Controller() override
;
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
;
44 virtual bool smpAware() const override
;
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;
50 /// slowly calculate (and cache) hi/lo watermarks and similar limits
53 /// called when the entry is no longer needed by any transaction
54 void handleIdleEntry(StoreEntry
&);
56 /// called to get rid of no longer needed entry data in RAM, if any
57 void memoryOut(StoreEntry
&, const bool preserveSwappable
);
59 /// update old entry metadata and HTTP headers using a newer entry
60 void updateOnNotModified(StoreEntry
*old
, const StoreEntry
&newer
);
62 /// makes the entry available for collapsing future requests
63 void allowCollapsing(StoreEntry
*, const RequestFlags
&, const HttpRequestMethod
&);
65 /// marks the entry completed for collapsed requests
66 void transientsCompleteWriting(StoreEntry
&);
68 /// Update local intransit entry after changes made by appending worker.
69 void syncCollapsed(const sfileno
);
71 /// calls Root().transients->abandon() if transients are tracked
72 void transientsAbandon(StoreEntry
&);
74 /// number of the transient entry readers some time ago
75 int transientReaders(const StoreEntry
&) const;
77 /// disassociates the entry from the intransit table
78 void transientsDisconnect(MemObject
&);
80 /// removes the entry from the memory cache
81 void memoryUnlink(StoreEntry
&);
83 /// disassociates the entry from the memory cache, preserving cached data
84 void memoryDisconnect(StoreEntry
&);
86 /// \returns an iterator for all Store entries
87 StoreSearch
*search();
89 /// the number of cache_dirs being rebuilt; TODO: move to Disks::Rebuilding
90 static int store_dirs_rebuilding
;
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
);
98 StoreEntry
*find(const cache_key
*key
);
99 bool keepForLocalMemoryCache(StoreEntry
&e
) const;
100 bool anchorCollapsed(StoreEntry
&, bool &inSync
);
102 Disks
*swapDir
; ///< summary view of all disk caches
103 Memory
*memStore
; ///< memory cache
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
;
111 /// safely access controller singleton
112 extern Controller
&Root();
114 /// initialize the storage module; a custom root is used by unit tests only
115 extern void Init(Controller
*root
= nullptr);
118 extern void FreeMemory();
122 #endif /* SQUID_STORE_CONTROLLER_H */