]> git.ipfire.org Git - thirdparty/squid.git/blame - src/store/Storage.h
SourceFormat Enforcement
[thirdparty/squid.git] / src / store / Storage.h
CommitLineData
2745fea5 1/*
4ac4a490 2 * Copyright (C) 1996-2017 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_STORAGE_H
10#define SQUID_STORE_STORAGE_H
11
12#include "base/RefCount.h"
13#include "store/forward.h"
14
15class StoreInfoStats;
16
17namespace Store {
18
19/// A "response storage" abstraction.
20/// This API is shared among Controller and Controlled classes.
21class Storage: public RefCountable
22{
23public:
24 virtual ~Storage() {}
25
26 /// create system resources needed for this store to operate in the future
27 virtual void create() = 0;
28
29 /// Start preparing the store for use. To check readiness, callers should
30 /// use readable() and writable() methods.
31 virtual void init() = 0;
32
33 /// Retrieve a store entry from the store (blocking)
34 virtual StoreEntry *get(const cache_key *) = 0;
35
36 /**
37 * The maximum size the store will support in normal use. Inaccuracy is
38 * permitted, but may throw estimates for memory etc out of whack.
39 */
40 virtual uint64_t maxSize() const = 0;
41
42 /// the minimum size the store will shrink to via normal housekeeping
43 virtual uint64_t minSize() const = 0;
44
45 /// current size
46 virtual uint64_t currentSize() const = 0;
47
48 /// the total number of objects stored right now
49 virtual uint64_t currentCount() const = 0;
50
51 /// the maximum size of a storable object; -1 if unlimited
52 virtual int64_t maxObjectSize() const = 0;
53
54 /// collect statistics
55 virtual void getStats(StoreInfoStats &stats) const = 0;
56
57 /**
58 * Output stats to the provided store entry.
59 \todo make these calls asynchronous
60 */
61 virtual void stat(StoreEntry &e) const = 0;
62
63 /// expect an unlink() call after the entry becomes idle
64 virtual void markForUnlink(StoreEntry &e) = 0;
65
66 /// remove the entry from the store
67 virtual void unlink(StoreEntry &e) = 0;
68
69 /// called once every main loop iteration; TODO: Move to UFS code.
70 virtual int callback() { return 0; }
71
72 /// perform regular periodic maintenance; TODO: move to UFSSwapDir::Maintain
73 virtual void maintain() = 0;
74
75 /// prepare for shutdown
76 virtual void sync() {}
1a210de4
EB
77
78 /// whether this storage is capable of serving multiple workers;
79 /// a true result does not imply [lack of] non-SMP support because
80 /// [only] some SMP-aware storages also support non-SMP configss
81 virtual bool smpAware() const = 0;
2745fea5
AR
82};
83
84} // namespace Store
85
86#endif /* SQUID_STORE_STORAGE_H */
87