]> git.ipfire.org Git - thirdparty/squid.git/blob - src/Transients.h
8e31a770e7c9bd2bce8c11055a158750e0aa7fc7
[thirdparty/squid.git] / src / Transients.h
1 #ifndef SQUID_TRANSIENTS_H
2 #define SQUID_TRANSIENTS_H
3
4 #include "http/MethodType.h"
5 #include "ipc/mem/Page.h"
6 #include "ipc/mem/PageStack.h"
7 #include "ipc/StoreMap.h"
8 #include "Store.h"
9
10 // StoreEntry restoration info not already stored by Ipc::StoreMap
11 struct TransientsMapExtras {
12 char url[MAX_URL+1]; ///< Request-URI; TODO: decrease MAX_URL by one
13 RequestFlags reqFlags; ///< request flags
14 Http::MethodType reqMethod; ///< request method; extensions are not supported
15 };
16 typedef Ipc::StoreMapWithExtras<TransientsMapExtras> TransientsMap;
17
18 /// Stores HTTP entities in RAM. Current implementation uses shared memory.
19 /// Unlike a disk store (SwapDir), operations are synchronous (and fast).
20 class Transients: public Store, public Ipc::StoreMapCleaner
21 {
22 public:
23 Transients();
24 virtual ~Transients();
25
26 /// add an in-transit entry suitable for collapsing future requests
27 void put(StoreEntry *e, const RequestFlags &reqFlags, const HttpRequestMethod &reqMethod);
28
29 /// cache the entry or forget about it until the next considerKeeping call
30 /// XXX: remove void considerKeeping(StoreEntry &e);
31
32 /// whether e should be kept in local RAM for possible future caching
33 /// XXX: remove bool keepInLocalMemory(const StoreEntry &e) const;
34
35 /* Store API */
36 virtual int callback();
37 virtual StoreEntry * get(const cache_key *);
38 virtual void get(String const key , STOREGETCLIENT callback, void *cbdata);
39 virtual void init();
40 virtual uint64_t maxSize() const;
41 virtual uint64_t minSize() const;
42 virtual uint64_t currentSize() const;
43 virtual uint64_t currentCount() const;
44 virtual int64_t maxObjectSize() const;
45 virtual void getStats(StoreInfoStats &stats) const;
46 virtual void stat(StoreEntry &) const;
47 virtual StoreSearch *search(String const url, HttpRequest *);
48 virtual void reference(StoreEntry &);
49 virtual bool dereference(StoreEntry &, bool);
50 virtual void maintain();
51
52 static int64_t EntryLimit();
53
54 protected:
55 bool copyToShm(const StoreEntry &e, const sfileno index, const RequestFlags &reqFlags, const HttpRequestMethod &reqMethod);
56
57 // Ipc::StoreMapCleaner API
58 virtual void noteFreeMapSlice(const sfileno sliceId);
59
60 private:
61 TransientsMap *map; ///< index of mem-cached entries
62 };
63
64 // TODO: Why use Store as a base? We are not really a cache.
65
66 #endif /* SQUID_MEMSTORE_H */