1 | <?php |
||
8 | class CacheEntry |
||
9 | { |
||
10 | /** |
||
11 | * @var RequestInterface |
||
12 | */ |
||
13 | protected $request; |
||
14 | |||
15 | /** |
||
16 | * @var ResponseInterface |
||
17 | */ |
||
18 | protected $response; |
||
19 | |||
20 | /** |
||
21 | * This field is only use for serialize. |
||
22 | * Response::body is a stream and can't be serialized. |
||
23 | * |
||
24 | * @var string |
||
25 | */ |
||
26 | protected $responseBody; |
||
27 | |||
28 | /** |
||
29 | * @var \DateTime |
||
30 | */ |
||
31 | protected $staleAt; |
||
32 | |||
33 | /** |
||
34 | * @var \DateTime |
||
35 | */ |
||
36 | protected $staleIfErrorTo; |
||
37 | |||
38 | /** |
||
39 | * @var \DateTime |
||
40 | */ |
||
41 | protected $staleWhileRevalidateTo; |
||
42 | |||
43 | /** |
||
44 | * @var \DateTime |
||
45 | */ |
||
46 | protected $dateCreated; |
||
47 | |||
48 | /** |
||
49 | * Cached timestamp of staleAt variable. |
||
50 | * |
||
51 | * @var int |
||
52 | */ |
||
53 | private $timestampStale; |
||
54 | |||
55 | /** |
||
56 | * @param RequestInterface $request |
||
57 | * @param ResponseInterface $response |
||
58 | * @param \DateTime $staleAt |
||
59 | * @param \DateTime|null $staleIfErrorTo if null, detected with the headers (RFC 5861) |
||
60 | * @param \DateTime|null $staleWhileRevalidateTo |
||
61 | */ |
||
62 | public function __construct( |
||
91 | |||
92 | /** |
||
93 | * @return ResponseInterface |
||
94 | */ |
||
95 | public function getResponse() |
||
100 | |||
101 | /** |
||
102 | * @return RequestInterface |
||
103 | */ |
||
104 | public function getOriginalRequest() |
||
108 | |||
109 | /** |
||
110 | * @param RequestInterface $request |
||
111 | * @return bool |
||
112 | */ |
||
113 | public function isVaryEquals(RequestInterface $request) |
||
141 | |||
142 | /** |
||
143 | * @return \DateTime |
||
144 | */ |
||
145 | public function getStaleAt() |
||
149 | |||
150 | /** |
||
151 | * @return bool |
||
152 | */ |
||
153 | public function isFresh() |
||
157 | |||
158 | /** |
||
159 | * @return bool |
||
160 | */ |
||
161 | public function isStale() |
||
165 | |||
166 | /** |
||
167 | * @return int positive value equal staled |
||
168 | */ |
||
169 | public function getStaleAge() |
||
178 | |||
179 | /** |
||
180 | * @return bool |
||
181 | */ |
||
182 | public function serveStaleIfError() |
||
187 | |||
188 | /** |
||
189 | * @return bool |
||
190 | */ |
||
191 | public function staleWhileValidate() |
||
196 | |||
197 | /** |
||
198 | * @return bool |
||
199 | */ |
||
200 | public function hasValidationInformation() |
||
204 | |||
205 | /** |
||
206 | * @return int TTL in seconds (0 = infinite) |
||
207 | */ |
||
208 | public function getTTL() |
||
226 | |||
227 | /** |
||
228 | * @return int Age in seconds |
||
229 | */ |
||
230 | public function getAge() |
||
234 | |||
235 | public function __sleep() |
||
245 | |||
246 | public function __wakeup() |
||
256 | } |
||
257 |