133 time_t freshness_lifetime;
134 time_t response_time;
135 time_t corrected_initial_age;
137 bool must_revalidate;
141 pthread_mutex_t d_response_lock;
142 pthread_mutex_t d_response_write_lock;
145 friend class HTTPCacheTable;
146 friend class HTTPCacheTest;
149 friend class DeleteCacheEntry;
150 friend class WriteOneCacheEntry;
151 friend class DeleteExpired;
152 friend class DeleteByHits;
153 friend class DeleteBySize;
156 string get_cachename() {
return cachename; }
157 string get_etag() {
return etag; }
158 time_t get_lm() {
return lm; }
159 time_t get_expires() {
return expires; }
160 time_t get_max_age() {
return max_age; }
161 void set_size(
unsigned long sz) { size = sz; }
162 time_t get_freshness_lifetime() {
return freshness_lifetime; }
163 time_t get_response_time() {
return response_time; }
164 time_t get_corrected_initial_age() {
return corrected_initial_age; }
165 bool get_must_revalidate() {
return must_revalidate; }
166 void set_no_cache(
bool state) { no_cache = state; }
167 bool is_no_cache() {
return no_cache; }
169 void lock_read_response() {
170 DBG(cerr <<
"Try locking read response... (" << hex << &d_response_lock << dec <<
") ");
171 int status = TRYLOCK(&d_response_lock);
174 LOCK(&d_response_write_lock);
175 UNLOCK(&d_response_write_lock);
180 DBGN(cerr <<
"Done" << endl);
183 void unlock_read_response() {
186 DBG(cerr <<
"Unlocking read response... (" << hex << &d_response_lock << dec <<
") ");
187 UNLOCK(&d_response_lock);
188 DBGN(cerr <<
"Done" << endl);
192 void lock_write_response() {
193 DBG(cerr <<
"locking write response... (" << hex << &d_response_lock << dec <<
") ");
194 LOCK(&d_response_lock);
195 LOCK(&d_response_write_lock);
196 DBGN(cerr <<
"Done" << endl);
199 void unlock_write_response() {
200 DBG(cerr <<
"Unlocking write response... (" << hex << &d_response_lock << dec <<
") ");
201 UNLOCK(&d_response_write_lock);
202 UNLOCK(&d_response_lock);
203 DBGN(cerr <<
"Done" << endl);
207 : url(
""), hash(-1), hits(0), cachename(
""), etag(
""), lm(-1), expires(-1), date(-1), age(-1), max_age(-1),
208 size(0), range(
false), freshness_lifetime(0), response_time(0), corrected_initial_age(0),
209 must_revalidate(
false), no_cache(
false), readers(0) {
210 INIT(&d_response_lock);
211 INIT(&d_response_write_lock);
213 CacheEntry(
const string &u)
214 : url(u), hash(-1), hits(0), cachename(
""), etag(
""), lm(-1), expires(-1), date(-1), age(-1), max_age(-1),
215 size(0), range(
false), freshness_lifetime(0), response_time(0), corrected_initial_age(0),
216 must_revalidate(
false), no_cache(
false), readers(0) {
217 INIT(&d_response_lock);
218 INIT(&d_response_write_lock);
294 void calculate_time(HTTPCacheTable::CacheEntry *entry,
int default_expiration, time_t request_time);