Squid Web Cache master
Loading...
Searching...
No Matches
Controller.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 1996-2025 The Squid Software Foundation and contributors
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_SRC_STORE_CONTROLLER_H
10#define SQUID_SRC_STORE_CONTROLLER_H
11
12#include "store/Storage.h"
13
14class MemObject;
15class RequestFlags;
17
18namespace Store {
19
22class Controller: public Storage
23{
24public:
25 Controller();
26
27 /* Storage API */
28 void create() override;
29 void init() override;
30 uint64_t maxSize() const override;
31 uint64_t minSize() const override;
32 uint64_t currentSize() const override;
33 uint64_t currentCount() const override;
34 int64_t maxObjectSize() const override;
35 void getStats(StoreInfoStats &stats) const override;
36 void stat(StoreEntry &) const override;
37 void sync() override;
38 void maintain() override;
39 void evictCached(StoreEntry &) override;
40 void evictIfFound(const cache_key *) override;
41 int callback() override;
42
46 StoreEntry *find(const cache_key *);
47
53 StoreEntry *peek(const cache_key *);
54
60
63 bool markedForDeletion(const cache_key *key) const;
64
67 bool markedForDeletionAndAbandoned(const StoreEntry &) const;
68
70 bool hasReadableDiskEntry(const StoreEntry &) const;
71
74 int64_t accumulateMore(StoreEntry &) const;
75
77 void configure();
78
81
85 void freeMemorySpace(const int spaceRequired);
86
88 void memoryOut(StoreEntry &, const bool preserveSwappable);
89
93
96
99 void addReading(StoreEntry *, const cache_key *);
100
103 void addWriting(StoreEntry *, const cache_key *);
104
106 bool transientsReader(const StoreEntry &) const;
107
109 bool transientsWriter(const StoreEntry &) const;
110
112 void syncCollapsed(const sfileno);
113
116
118 int transientReaders(const StoreEntry &) const;
119
122
125
128
130 static bool SmpAware();
131
134
135private:
136 ~Controller() override;
137
138 bool memoryCacheHasSpaceFor(const int pagesRequired) const;
139
140 void referenceBusy(StoreEntry &e);
141 bool dereferenceIdle(StoreEntry &, bool wantsLocalMemory);
142
143 void allowSharing(StoreEntry &, const cache_key *);
145
148 bool keepForLocalMemoryCache(StoreEntry &e) const;
150 void checkTransients(const StoreEntry &) const;
151 void checkFoundCandidate(const StoreEntry &) const;
152
156
161
164};
165
167extern Controller &Root();
168
169} // namespace Store
170
171#endif /* SQUID_SRC_STORE_CONTROLLER_H */
172
High-level store statistics used by mgr:info action. Used inside PODs!
Definition StoreStats.h:14
void memoryOut(StoreEntry &, const bool preserveSwappable)
called to get rid of no longer needed entry data in RAM, if any
void checkFoundCandidate(const StoreEntry &) const
flags problematic entries before find() commits to finalizing/returning them
void configure()
update configuration, including limits (re)calculation
~Controller() override
this destructor is never called because Controller singleton is immortal
Definition Controller.cc:46
StoreEntry * findCallbackXXX(const cache_key *)
bool markedForDeletionAndAbandoned(const StoreEntry &) const
StoreEntry * peekAtLocal(const cache_key *)
void checkTransients(const StoreEntry &) const
int transientReaders(const StoreEntry &) const
number of the transient entry readers some time ago
void noteStoppedSharedWriting(StoreEntry &)
adjust shared state after this worker stopped changing the entry
void addReading(StoreEntry *, const cache_key *)
void addWriting(StoreEntry *, const cache_key *)
uint64_t maxSize() const override
void handleIdleEntry(StoreEntry &)
called when the entry is no longer needed by any transaction
bool allowCollapsing(StoreEntry *, const RequestFlags &, const HttpRequestMethod &)
tries to make the entry available for collapsing future requests
void sync() override
prepare for shutdown
void stat(StoreEntry &) const override
bool transientsReader(const StoreEntry &) const
whether the entry is in "reading from Transients" I/O state
void referenceBusy(StoreEntry &e)
update reference counters of the recently touched entry
void freeMemorySpace(const int spaceRequired)
void maintain() override
perform regular periodic maintenance; TODO: move to UFSSwapDir::Maintain
Definition Controller.cc:87
void syncCollapsed(const sfileno)
Update local intransit entry after changes made by appending worker.
void getStats(StoreInfoStats &stats) const override
collect statistics
uint64_t minSize() const override
the minimum size the store will shrink to via normal housekeeping
void memoryDisconnect(StoreEntry &)
disassociates the entry from the memory cache, preserving cached data
bool hasReadableDiskEntry(const StoreEntry &) const
whether there is a disk entry with e.key
bool markedForDeletion(const cache_key *key) const
bool updateOnNotModified(StoreEntry *old, StoreEntry &e304)
void transientsDisconnect(StoreEntry &)
disassociates the entry from the intransit table
int64_t accumulateMore(StoreEntry &) const
bool memoryCacheHasSpaceFor(const int pagesRequired) const
whether the memory cache is allowed to store that many additional pages
static int store_dirs_rebuilding
the number of cache_dirs being rebuilt; TODO: move to Disks::Rebuilding
Definition Controller.h:133
int memoryPagesDebt_
Hack: Relays page shortage from freeMemorySpace() to handleIdleEntry().
Definition Controller.h:163
StoreSearch * search()
int64_t maxObjectSize() const override
the maximum size of a storable object; -1 if unlimited
bool anchorToCache(StoreEntry &)
void memoryEvictCached(StoreEntry &)
void init() override
Definition Controller.cc:53
Memory * sharedMemStore
memory cache that multiple workers can use
Definition Controller.h:154
static bool SmpAware()
whether there are any SMP-aware storages
bool transientsWriter(const StoreEntry &) const
whether the entry is in "writing to Transients" I/O state
void create() override
create system resources needed for this store to operate in the future
Definition Controller.cc:73
uint64_t currentSize() const override
current size
Transients * transients
Definition Controller.h:160
bool dereferenceIdle(StoreEntry &, bool wantsLocalMemory)
void evictCached(StoreEntry &) override
void allowSharing(StoreEntry &, const cache_key *)
indexes and adds SMP-tracking for an ephemeral peek() result
bool localMemStore
whether local (non-shared) memory cache is enabled
Definition Controller.h:155
void transientsUnlinkByKeyIfFound(const cache_key *)
void evictIfFound(const cache_key *) override
StoreEntry * find(const cache_key *)
uint64_t currentCount() const override
the total number of objects stored right now
int callback() override
called once every main loop iteration; TODO: Move to UFS code.
bool keepForLocalMemoryCache(StoreEntry &e) const
whether e should be kept in local RAM for possible future caching
Disks * disks
summary view of all disk caches (including none); never nil
Definition Controller.h:153
StoreEntry * peek(const cache_key *)
summary view of all disk caches (cache_dirs) combined
Definition Disks.h:19
Controller & Root()
safely access controller singleton
unsigned char cache_key
Store key.
Definition forward.h:29
signed_int32_t sfileno
Definition forward.h:22