]> git.ipfire.org Git - thirdparty/squid.git/blob - src/Store.h
Summary: Merge disk-factoring.
[thirdparty/squid.git] / src / Store.h
1
2 /*
3 * $Id: Store.h,v 1.11 2003/07/22 15:23:01 robertc Exp $
4 *
5 *
6 * SQUID Web Proxy Cache http://www.squid-cache.org/
7 * ----------------------------------------------------------
8 *
9 * Squid is the result of efforts by numerous individuals from
10 * the Internet community; see the CONTRIBUTORS file for full
11 * details. Many organizations have provided support for Squid's
12 * development; see the SPONSORS file for full details. Squid is
13 * Copyrighted (C) 2001 by the Regents of the University of
14 * California; see the COPYRIGHT file for full details. Squid
15 * incorporates software developed and/or copyrighted by other
16 * sources; see the CREDITS file for full details.
17 *
18 * This program is free software; you can redistribute it and/or modify
19 * it under the terms of the GNU General Public License as published by
20 * the Free Software Foundation; either version 2 of the License, or
21 * (at your option) any later version.
22 *
23 * This program is distributed in the hope that it will be useful,
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 * GNU General Public License for more details.
27 *
28 * You should have received a copy of the GNU General Public License
29 * along with this program; if not, write to the Free Software
30 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
31 *
32 */
33
34 #ifndef SQUID_STORE_H
35 #define SQUID_STORE_H
36
37 #include "StoreIOBuffer.h"
38 #include "Range.h"
39 #include "CommRead.h"
40
41 #if ESI
42 #include "ESIElement.h"
43 #endif
44
45 class StoreClient;
46
47 class MemObject;
48
49 class StoreEntry : public hash_link
50 {
51
52 public:
53 static DeferredRead::DeferrableRead DeferReader;
54 bool checkDeferRead(int fd) const;
55
56 virtual const char *getMD5Text() const;
57 virtual ~StoreEntry(){}
58
59 virtual HttpReply const *getReply() const;
60 virtual void write (StoreIOBuffer);
61 virtual _SQUID_INLINE_ bool isEmpty() const;
62 virtual size_t bytesWanted(Range<size_t> const) const;
63 virtual void complete();
64 virtual store_client_t storeClientType() const;
65 virtual char const *getSerialisedMetaData();
66 virtual bool swapoutPossible();
67 virtual void trimMemory();
68
69 void delayAwareRead(int fd, char *buf, int len, IOCB *handler, void *data);
70
71 void setNoDelay (bool const);
72 bool modifiedSince(request_t * request) const;
73
74 MemObject *mem_obj;
75 RemovalPolicyNode repl;
76 /* START OF ON-DISK STORE_META_STD TLV field */
77 time_t timestamp;
78 time_t lastref;
79 time_t expires;
80 time_t lastmod;
81 size_t swap_file_sz;
82 u_short refcount;
83 u_short flags;
84 /* END OF ON-DISK STORE_META_STD */
85
86 sfileno swap_filen:
87 25;
88
89 sdirno swap_dirn:
90 7;
91 u_short lock_count; /* Assume < 65536! */
92
93 mem_status_t mem_status:
94 3;
95
96 ping_status_t ping_status:
97 3;
98
99 store_status_t store_status:
100 3;
101
102 swap_status_t swap_status:
103 3;
104
105 public:
106 static size_t inUseCount();
107 static void getPublicByRequestMethod(StoreClient * aClient, request_t * request, const method_t method);
108 static void getPublicByRequest(StoreClient * aClient, request_t * request);
109 static void getPublic(StoreClient * aClient, const char *uri, const method_t method);
110
111 virtual bool isNull()
112 {
113 return false;
114 }
115
116 void *operator new(size_t byteCount);
117 void operator delete(void *address);
118 void setReleaseFlag();
119 #if ESI
120
121 ESIElement::Pointer cachedESITree;
122 #endif
123
124 private:
125 static MemPool *pool;
126
127 bool validLength() const;
128 };
129
130 class NullStoreEntry:public StoreEntry
131 {
132
133 public:
134 static NullStoreEntry *getInstance();
135 bool isNull()
136 {
137 return true;
138 }
139
140 const char *getMD5Text() const;
141 _SQUID_INLINE_ HttpReply const *getReply() const;
142 void write (StoreIOBuffer){}
143
144 bool isEmpty () const {return true;}
145
146 virtual size_t bytesWanted(Range<size_t> const aRange) const { assert (aRange.size());return aRange.end - 1;}
147
148 void operator delete(void *address);
149 void complete(){}
150
151 private:
152 store_client_t storeClientType() const{return STORE_MEM_CLIENT;}
153
154 char const *getSerialisedMetaData();
155 bool swapoutPossible() {return false;}
156
157 void trimMemory() {}
158
159
160 static NullStoreEntry _instance;
161 };
162
163 SQUIDCEXTERN size_t storeEntryInUse();
164 SQUIDCEXTERN off_t storeLowestMemReaderOffset(const StoreEntry * entry);
165 SQUIDCEXTERN const char *storeEntryFlags(const StoreEntry *);
166 SQUIDCEXTERN int storeEntryLocked(const StoreEntry *);
167 extern void storeEntryReplaceObject(StoreEntry *, HttpReply *);
168
169 SQUIDCEXTERN StoreEntry *new_StoreEntry(int, const char *, const char *);
170 SQUIDCEXTERN StoreEntry *storeGet(const cache_key *);
171 SQUIDCEXTERN StoreEntry *storeGetPublic(const char *uri, const method_t method);
172 SQUIDCEXTERN StoreEntry *storeGetPublicByRequest(request_t * request);
173 SQUIDCEXTERN StoreEntry *storeGetPublicByRequestMethod(request_t * request, const method_t method);
174 SQUIDCEXTERN StoreEntry *storeCreateEntry(const char *, const char *, request_flags, method_t);
175 SQUIDCEXTERN void storeSetPublicKey(StoreEntry *);
176 SQUIDCEXTERN void storeCreateMemObject(StoreEntry *, const char *, const char *);
177 SQUIDCEXTERN void storeInit(void);
178 SQUIDCEXTERN void storeAbort(StoreEntry *);
179 SQUIDCEXTERN void storeAppend(StoreEntry *, const char *, int);
180 SQUIDCEXTERN void storeLockObject(StoreEntry *);
181 SQUIDCEXTERN void storeRelease(StoreEntry *);
182 SQUIDCEXTERN int storeUnlockObject(StoreEntry *);
183 SQUIDCEXTERN EVH storeMaintainSwapSpace;
184 SQUIDCEXTERN void storeExpireNow(StoreEntry *);
185 SQUIDCEXTERN void storeReleaseRequest(StoreEntry *);
186 SQUIDCEXTERN void storeConfigure(void);
187 SQUIDCEXTERN int storeCheckNegativeHit(StoreEntry *);
188 SQUIDCEXTERN void storeNegativeCache(StoreEntry *);
189 SQUIDCEXTERN void storeFreeMemory(void);
190 SQUIDCEXTERN int expiresMoreThan(time_t, time_t);
191 SQUIDCEXTERN int storeEntryValidToSend(StoreEntry *);
192 SQUIDCEXTERN void storeTimestampsSet(StoreEntry *);
193 SQUIDCEXTERN void storeRegisterAbort(StoreEntry * e, STABH * cb, void *);
194 SQUIDCEXTERN void storeUnregisterAbort(StoreEntry * e);
195 SQUIDCEXTERN void storeEntryDump(const StoreEntry * e, int debug_lvl);
196 SQUIDCEXTERN const char *storeUrl(const StoreEntry *);
197 SQUIDCEXTERN void storeBuffer(StoreEntry *);
198 SQUIDCEXTERN void storeBufferFlush(StoreEntry *);
199 SQUIDCEXTERN void storeHashInsert(StoreEntry * e, const cache_key *);
200 SQUIDCEXTERN void storeSetMemStatus(StoreEntry * e, mem_status_t);
201 #if STDC_HEADERS
202 SQUIDCEXTERN void
203 storeAppendPrintf(StoreEntry *, const char *,...) PRINTF_FORMAT_ARG2;
204 #else
205 SQUIDCEXTERN void storeAppendPrintf();
206 #endif
207 SQUIDCEXTERN void storeAppendVPrintf(StoreEntry *, const char *, va_list ap);
208 SQUIDCEXTERN int storeCheckCachable(StoreEntry * e);
209 SQUIDCEXTERN void storeSetPrivateKey(StoreEntry *);
210 SQUIDCEXTERN ssize_t objectLen(const StoreEntry * e);
211 SQUIDCEXTERN int contentLen(const StoreEntry * e);
212 SQUIDCEXTERN int storeTooManyDiskFilesOpen(void);
213 SQUIDCEXTERN void storeEntryReset(StoreEntry *);
214 SQUIDCEXTERN void storeHeapPositionUpdate(StoreEntry *, SwapDir *);
215 SQUIDCEXTERN void storeSwapFileNumberSet(StoreEntry * e, sfileno filn);
216 SQUIDCEXTERN void storeFsInit(void);
217 SQUIDCEXTERN void storeFsDone(void);
218 SQUIDCEXTERN void storeReplAdd(const char *, REMOVALPOLICYCREATE *);
219
220 #ifdef _USE_INLINE_
221 #include "Store.cci"
222 #endif
223
224 #endif /* SQUID_STORE_H */