]>
Commit | Line | Data |
---|---|---|
2745fea5 | 1 | /* |
b8ae064d | 2 | * Copyright (C) 1996-2023 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 | ||
ff9d9458 FC |
9 | #ifndef SQUID_SRC_STORE_STORAGE_H |
10 | #define SQUID_SRC_STORE_STORAGE_H | |
2745fea5 AR |
11 | |
12 | #include "base/RefCount.h" | |
4310f8b0 | 13 | #include "http/RequestMethod.h" |
2745fea5 | 14 | #include "store/forward.h" |
4310f8b0 | 15 | #include "store_key_md5.h" |
2745fea5 AR |
16 | |
17 | class StoreInfoStats; | |
18 | ||
19 | namespace Store { | |
20 | ||
21 | /// A "response storage" abstraction. | |
22 | /// This API is shared among Controller and Controlled classes. | |
23 | class Storage: public RefCountable | |
24 | { | |
25 | public: | |
337b9aa4 | 26 | ~Storage() override {} |
2745fea5 AR |
27 | |
28 | /// create system resources needed for this store to operate in the future | |
29 | virtual void create() = 0; | |
30 | ||
31 | /// Start preparing the store for use. To check readiness, callers should | |
32 | /// use readable() and writable() methods. | |
33 | virtual void init() = 0; | |
34 | ||
2745fea5 AR |
35 | /** |
36 | * The maximum size the store will support in normal use. Inaccuracy is | |
37 | * permitted, but may throw estimates for memory etc out of whack. | |
38 | */ | |
39 | virtual uint64_t maxSize() const = 0; | |
40 | ||
41 | /// the minimum size the store will shrink to via normal housekeeping | |
42 | virtual uint64_t minSize() const = 0; | |
43 | ||
44 | /// current size | |
45 | virtual uint64_t currentSize() const = 0; | |
46 | ||
47 | /// the total number of objects stored right now | |
48 | virtual uint64_t currentCount() const = 0; | |
49 | ||
50 | /// the maximum size of a storable object; -1 if unlimited | |
51 | virtual int64_t maxObjectSize() const = 0; | |
52 | ||
53 | /// collect statistics | |
54 | virtual void getStats(StoreInfoStats &stats) const = 0; | |
55 | ||
56 | /** | |
57 | * Output stats to the provided store entry. | |
9837567d | 58 | * TODO: make these calls asynchronous |
2745fea5 AR |
59 | */ |
60 | virtual void stat(StoreEntry &e) const = 0; | |
61 | ||
4310f8b0 EB |
62 | /// Prevent new get() calls from returning the matching entry. |
63 | /// If the matching entry is unused, it may be removed from the store now. | |
64 | /// The store entry is matched using either `e` attachment info or `e.key`. | |
65 | virtual void evictCached(StoreEntry &e) = 0; | |
2745fea5 | 66 | |
4310f8b0 EB |
67 | /// An evictCached() equivalent for callers that did not get() a StoreEntry. |
68 | /// Callers with StoreEntry objects must use evictCached() instead. | |
69 | virtual void evictIfFound(const cache_key *) = 0; | |
2745fea5 AR |
70 | |
71 | /// called once every main loop iteration; TODO: Move to UFS code. | |
72 | virtual int callback() { return 0; } | |
73 | ||
74 | /// perform regular periodic maintenance; TODO: move to UFSSwapDir::Maintain | |
75 | virtual void maintain() = 0; | |
76 | ||
77 | /// prepare for shutdown | |
78 | virtual void sync() {} | |
79 | }; | |
80 | ||
81 | } // namespace Store | |
82 | ||
ff9d9458 | 83 | #endif /* SQUID_SRC_STORE_STORAGE_H */ |
2745fea5 | 84 |