]> git.ipfire.org Git - thirdparty/squid.git/blame - src/store/Controlled.h
Source Format Enforcement (#763)
[thirdparty/squid.git] / src / store / Controlled.h
CommitLineData
2745fea5 1/*
f70aedc4 2 * Copyright (C) 1996-2021 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_CONTROLLED_H
10#define SQUID_STORE_CONTROLLED_H
11
12#include "store/Storage.h"
13
14namespace Store {
15
16/// Storage controlled by a Controller.
17/// This API is shared among Disks, Disk, Memory caches and Transients.
18class Controlled: public Storage
19{
20public:
4310f8b0
EB
21 /// \returns a possibly unlocked/unregistered stored entry with key (or nil)
22 /// The returned entry might not match the caller's Store ID or method. The
23 /// caller must abandon()/release() the entry or register it with Root().
24 /// This method must not trigger slow I/O operations (e.g., disk swap in).
25 virtual StoreEntry *get(const cache_key *) = 0;
26
2745fea5
AR
27 /// somebody needs this entry (many cache replacement policies need to know)
28 virtual void reference(StoreEntry &e) = 0;
29
30 /// somebody no longer needs this entry (usually after calling reference())
31 /// return false iff the idle entry should be destroyed
32 virtual bool dereference(StoreEntry &e) = 0;
33
abf396ec
AR
34 /// make stored metadata and HTTP headers the same as in the given entry
35 virtual void updateHeaders(StoreEntry *) {}
36
4310f8b0 37 /// If Transients entry cannot be attached to this storage, return false.
2745fea5 38 /// If the entry is not found, return false. Otherwise, return true after
4310f8b0
EB
39 /// tying the entry to this cache and setting inSync to updateAnchored().
40 virtual bool anchorToCache(StoreEntry &, bool &/*inSync*/) { return false; }
2745fea5 41
4310f8b0
EB
42 /// Update a local Transients entry with fresh info from this cache (if any).
43 /// Return true iff the cache supports Transients entries and
44 /// the given local Transients entry is now in sync with this storage.
45 virtual bool updateAnchored(StoreEntry &) { return false; }
2745fea5
AR
46};
47
48} // namespace Store
49
50#endif /* SQUID_STORE_CONTROLLED_H */
7d84d4ca 51