]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/store/Controller.h
2 * Copyright (C) 1996-2016 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
;
45 /// called when the entry is no longer needed by any transaction
46 void handleIdleEntry(StoreEntry
&);
48 /// called to get rid of no longer needed entry data in RAM, if any
49 void memoryOut(StoreEntry
&, const bool preserveSwappable
);
51 /// makes the entry available for collapsing future requests
52 void allowCollapsing(StoreEntry
*, const RequestFlags
&, const HttpRequestMethod
&);
54 /// marks the entry completed for collapsed requests
55 void transientsCompleteWriting(StoreEntry
&);
57 /// Update local intransit entry after changes made by appending worker.
58 void syncCollapsed(const sfileno
);
60 /// calls Root().transients->abandon() if transients are tracked
61 void transientsAbandon(StoreEntry
&);
63 /// number of the transient entry readers some time ago
64 int transientReaders(const StoreEntry
&) const;
66 /// disassociates the entry from the intransit table
67 void transientsDisconnect(MemObject
&);
69 /// removes the entry from the memory cache
70 void memoryUnlink(StoreEntry
&);
72 /// disassociates the entry from the memory cache, preserving cached data
73 void memoryDisconnect(StoreEntry
&);
75 /// \returns an iterator for all Store entries
76 StoreSearch
*search();
78 /// the number of cache_dirs being rebuilt; TODO: move to Disks::Rebuilding
79 static int store_dirs_rebuilding
;
82 /// update reference counters of the recently touched entry
83 void referenceBusy(StoreEntry
&e
);
84 /// dereference() an idle entry and return true if the entry should be deleted
85 bool dereferenceIdle(StoreEntry
&, bool wantsLocalMemory
);
87 StoreEntry
*find(const cache_key
*key
);
88 bool keepForLocalMemoryCache(StoreEntry
&e
) const;
89 bool anchorCollapsed(StoreEntry
&, bool &inSync
);
91 Disks
*swapDir
; ///< summary view of all disk caches
92 Memory
*memStore
; ///< memory cache
94 /// A shared table of public store entries that do not know whether they
95 /// will belong to a memory cache, a disk cache, or will be uncachable
96 /// when the response header comes. Used for SMP collapsed forwarding.
97 Transients
*transients
;
100 /// safely access controller singleton
101 extern Controller
&Root();
103 /// initialize the storage module; a custom root is used by unit tests only
104 extern void Init(Controller
*root
= nullptr);
107 extern void FreeMemory();
111 #endif /* SQUID_STORE_CONTROLLER_H */