]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/store/Storage.h
2 * Copyright (C) 1996-2017 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_STORAGE_H
10 #define SQUID_STORE_STORAGE_H
12 #include "base/RefCount.h"
13 #include "store/forward.h"
19 /// A "response storage" abstraction.
20 /// This API is shared among Controller and Controlled classes.
21 class Storage
: public RefCountable
26 /// create system resources needed for this store to operate in the future
27 virtual void create() = 0;
29 /// Start preparing the store for use. To check readiness, callers should
30 /// use readable() and writable() methods.
31 virtual void init() = 0;
33 /// Retrieve a store entry from the store (blocking)
34 virtual StoreEntry
*get(const cache_key
*) = 0;
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.
40 virtual uint64_t maxSize() const = 0;
42 /// the minimum size the store will shrink to via normal housekeeping
43 virtual uint64_t minSize() const = 0;
46 virtual uint64_t currentSize() const = 0;
48 /// the total number of objects stored right now
49 virtual uint64_t currentCount() const = 0;
51 /// the maximum size of a storable object; -1 if unlimited
52 virtual int64_t maxObjectSize() const = 0;
54 /// collect statistics
55 virtual void getStats(StoreInfoStats
&stats
) const = 0;
58 * Output stats to the provided store entry.
59 \todo make these calls asynchronous
61 virtual void stat(StoreEntry
&e
) const = 0;
63 /// expect an unlink() call after the entry becomes idle
64 virtual void markForUnlink(StoreEntry
&e
) = 0;
66 /// remove the entry from the store
67 virtual void unlink(StoreEntry
&e
) = 0;
69 /// called once every main loop iteration; TODO: Move to UFS code.
70 virtual int callback() { return 0; }
72 /// perform regular periodic maintenance; TODO: move to UFSSwapDir::Maintain
73 virtual void maintain() = 0;
75 /// prepare for shutdown
76 virtual void sync() {}
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;
86 #endif /* SQUID_STORE_STORAGE_H */