3 * $Id: Store.h,v 1.11 2003/07/22 15:23:01 robertc Exp $
6 * SQUID Web Proxy Cache http://www.squid-cache.org/
7 * ----------------------------------------------------------
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.
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.
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.
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.
37 #include "StoreIOBuffer.h"
42 #include "ESIElement.h"
49 class StoreEntry
: public hash_link
53 static DeferredRead::DeferrableRead DeferReader
;
54 bool checkDeferRead(int fd
) const;
56 virtual const char *getMD5Text() const;
57 virtual ~StoreEntry(){}
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();
69 void delayAwareRead(int fd
, char *buf
, int len
, IOCB
*handler
, void *data
);
71 void setNoDelay (bool const);
72 bool modifiedSince(request_t
* request
) const;
75 RemovalPolicyNode repl
;
76 /* START OF ON-DISK STORE_META_STD TLV field */
84 /* END OF ON-DISK STORE_META_STD */
91 u_short lock_count
; /* Assume < 65536! */
93 mem_status_t mem_status
:
96 ping_status_t ping_status
:
99 store_status_t store_status
:
102 swap_status_t swap_status
:
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
);
111 virtual bool isNull()
116 void *operator new(size_t byteCount
);
117 void operator delete(void *address
);
118 void setReleaseFlag();
121 ESIElement::Pointer cachedESITree
;
125 static MemPool
*pool
;
127 bool validLength() const;
130 class NullStoreEntry
:public StoreEntry
134 static NullStoreEntry
*getInstance();
140 const char *getMD5Text() const;
141 _SQUID_INLINE_ HttpReply
const *getReply() const;
142 void write (StoreIOBuffer
){}
144 bool isEmpty () const {return true;}
146 virtual size_t bytesWanted(Range
<size_t> const aRange
) const { assert (aRange
.size());return aRange
.end
- 1;}
148 void operator delete(void *address
);
152 store_client_t
storeClientType() const{return STORE_MEM_CLIENT
;}
154 char const *getSerialisedMetaData();
155 bool swapoutPossible() {return false;}
160 static NullStoreEntry _instance
;
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
*);
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
);
203 storeAppendPrintf(StoreEntry
*, const char *,...) PRINTF_FORMAT_ARG2
;
205 SQUIDCEXTERN
void storeAppendPrintf();
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
*);
224 #endif /* SQUID_STORE_H */