]> git.ipfire.org Git - thirdparty/squid.git/blob - src/StoreHashIndex.h
SourceFormat Enforcement
[thirdparty/squid.git] / src / StoreHashIndex.h
1 /*
2 * Copyright (C) 1996-2015 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_STOREHASHINDEX_H
10 #define SQUID_STOREHASHINDEX_H
11
12 #include "Store.h"
13 #include "StoreSearch.h"
14
15 /* A summary store that indexs all its children
16 * into a memory hash
17 */
18
19 class StoreSearch;
20
21 class StoreHashIndex : public Store
22 {
23
24 public:
25 StoreHashIndex();
26 StoreHashIndex(StoreHashIndex const &); /* to cause link failures */
27 virtual ~StoreHashIndex();
28 virtual int callback();
29 virtual void create();
30
31 virtual StoreEntry * get
32 (const cache_key *);
33
34 virtual void get
35 (String const, STOREGETCLIENT, void * cbdata);
36
37 virtual void init();
38
39 virtual void sync();
40
41 virtual uint64_t maxSize() const;
42
43 virtual uint64_t minSize() const;
44
45 virtual uint64_t currentSize() const;
46
47 virtual uint64_t currentCount() const;
48
49 virtual int64_t maxObjectSize() const;
50
51 virtual void getStats(StoreInfoStats &stats) const;
52 virtual void stat(StoreEntry&) const;
53
54 virtual void reference(StoreEntry&);
55
56 virtual bool dereference(StoreEntry&, bool);
57
58 virtual void maintain();
59
60 virtual StoreSearch *search(String const url, HttpRequest *);
61
62 private:
63 /* migration logic */
64 StorePointer store(int const x) const;
65 SwapDir &dir(int const idx) const;
66 };
67
68 class StoreHashIndexEntry : public StoreEntry
69 {};
70
71 class StoreSearchHashIndex : public StoreSearch
72 {
73 CBDATA_CLASS(StoreSearchHashIndex);
74
75 public:
76 StoreSearchHashIndex(RefCount<StoreHashIndex> sd);
77 StoreSearchHashIndex(StoreSearchHashIndex const &);
78 virtual ~StoreSearchHashIndex();
79 /* Iterator API - garh, wrong place */
80 /* callback the client when a new StoreEntry is available
81 * or an error occurs
82 */
83 virtual void next(void (callback)(void *cbdata), void *cbdata);
84 /* return true if a new StoreEntry is immediately available */
85 virtual bool next();
86 virtual bool error() const;
87 virtual bool isDone() const;
88 virtual StoreEntry *currentItem();
89
90 RefCount<StoreHashIndex> sd;
91
92 private:
93 void copyBucket();
94 void (*callback)(void *cbdata);
95 void *cbdata;
96 bool _done;
97 int bucket;
98 std::vector<StoreEntry *> entries;
99 };
100
101 #endif /* SQUID_STOREHASHINDEX_H */
102