]>
Commit | Line | Data |
---|---|---|
9487bae9 AR |
1 | /* |
2 | * $Id$ | |
3 | */ | |
4 | ||
5 | #ifndef SQUID_MEMSTORE_H | |
6 | #define SQUID_MEMSTORE_H | |
7 | ||
8 | #include "Store.h" | |
9 | #include "MemStoreMap.h" | |
10 | ||
11 | /// Stores HTTP entities in RAM. Current implementation uses shared memory. | |
12 | /// Unlike a disk store (SwapDir), operations are synchronous (and fast). | |
7f6748c8 | 13 | class MemStore: public Store, public Ipc::StoreMapCleaner { |
9487bae9 AR |
14 | public: |
15 | MemStore(); | |
16 | virtual ~MemStore(); | |
17 | ||
18 | /// cache the entry or forget about it until the next considerKeeping call | |
19 | void considerKeeping(StoreEntry &e); | |
20 | ||
21 | /* Store API */ | |
22 | virtual int callback(); | |
23 | virtual StoreEntry * get(const cache_key *); | |
24 | virtual void get(String const key , STOREGETCLIENT callback, void *cbdata); | |
25 | virtual void init(); | |
26 | virtual uint64_t maxSize() const; | |
27 | virtual uint64_t minSize() const; | |
39c1e1d9 DK |
28 | virtual uint64_t currentSize() const; |
29 | virtual uint64_t currentCount() const; | |
af2fda07 | 30 | virtual int64_t maxObjectSize() const; |
9487bae9 AR |
31 | virtual void stat(StoreEntry &) const; |
32 | virtual StoreSearch *search(String const url, HttpRequest *); | |
33 | virtual void reference(StoreEntry &); | |
34 | virtual void dereference(StoreEntry &); | |
35 | virtual void maintain(); | |
36 | virtual void updateSize(int64_t size, int sign); | |
37 | ||
a4555399 AR |
38 | /// initializes shared memory segments before they are used by workers |
39 | static void Init(); | |
40 | ||
9487bae9 AR |
41 | protected: |
42 | bool willFit(int64_t needed); | |
43 | void keep(StoreEntry &e); | |
44 | ||
45 | bool copyToShm(StoreEntry &e, MemStoreMap::Extras &extras); | |
46 | bool copyFromShm(StoreEntry &e, const MemStoreMap::Extras &extras); | |
47 | ||
7f6748c8 AR |
48 | // Ipc::StoreMapCleaner API |
49 | virtual void cleanReadable(const sfileno fileno); | |
50 | ||
a4555399 AR |
51 | static int64_t EntryLimit(); |
52 | ||
9487bae9 AR |
53 | private: |
54 | MemStoreMap *map; ///< index of mem-cached entries | |
17cf0a47 | 55 | uint64_t theCurrentSize; ///< currently used space in the storage area |
9487bae9 AR |
56 | }; |
57 | ||
58 | // Why use Store as a base? MemStore and SwapDir are both "caches". | |
59 | ||
60 | // Why not just use a SwapDir API? That would not help much because Store has | |
61 | // to check/update memory cache separately from the disk cache. And same API | |
62 | // would hurt because we can support synchronous get/put, unlike the disks. | |
63 | ||
64 | #endif /* SQUID_MEMSTORE_H */ |