]> git.ipfire.org Git - thirdparty/squid.git/blob - src/store/Controlled.h
d250ce10530d88650390c6e4eba8564f2e875b76
[thirdparty/squid.git] / src / store / Controlled.h
1 /*
2 * Copyright (C) 1996-2019 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_STORE_CONTROLLED_H
10 #define SQUID_STORE_CONTROLLED_H
11
12 #include "store/Storage.h"
13
14 namespace Store {
15
16 /// Storage controlled by a Controller.
17 /// This API is shared among Disks, Disk, Memory caches and Transients.
18 class Controlled: public Storage
19 {
20 public:
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
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
34 /// make stored metadata and HTTP headers the same as in the given entry
35 virtual void updateHeaders(StoreEntry *) {}
36
37 /// If Transients entry cannot be attached to this storage, return false.
38 /// If the entry is not found, return false. Otherwise, return true after
39 /// tying the entry to this cache and setting inSync to updateAnchored().
40 virtual bool anchorToCache(StoreEntry &, bool &/*inSync*/) { return false; }
41
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; }
46 };
47
48 } // namespace Store
49
50 #endif /* SQUID_STORE_CONTROLLED_H */
51