Skip to content

Commit 3b2f720

Browse files
committed
style fix
1 parent 824b9aa commit 3b2f720

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/CachePlugin.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public function handleRequest(RequestInterface $request, callable $next, callabl
9999
// The cached response we have is still valid
100100
$data = $cacheItem->get();
101101
$data['expiresAt'] = time() + $this->getMaxAge($response);
102-
$cacheItem->set($data)->expiresAfter($this->config['cache_lifetime']);
102+
$cacheItem->set($data)->expiresAfter($this->config['cache_lifetime'] + $data['expiresAt']);
103103
$this->pool->save($cacheItem);
104104

105105
return $this->createResponseFromCacheItem($cacheItem);
@@ -114,12 +114,13 @@ public function handleRequest(RequestInterface $request, callable $next, callabl
114114
$response = $response->withBody($this->streamFactory->createStream($body));
115115
}
116116

117+
$expiresAt = time() + $this->getMaxAge($response);
117118
$cacheItem
118-
->expiresAfter($this->config['cache_lifetime'])
119+
->expiresAfter($this->config['cache_lifetime'] + $expiresAt)
119120
->set([
120121
'response' => $response,
121122
'body' => $body,
122-
'expiresAt' => time() + $this->getMaxAge($response),
123+
'expiresAt' => $expiresAt,
123124
'createdAt' => time(),
124125
'etag' => $response->getHeader('ETag'),
125126
]);
@@ -268,7 +269,7 @@ private function getModifiedAt(CacheItemInterface $cacheItem)
268269
{
269270
$data = $cacheItem->get();
270271
if (!isset($data['createdAt'])) {
271-
return null;
272+
return;
272273
}
273274

274275
return $data['createdAt'];
@@ -285,17 +286,17 @@ private function getETag(CacheItemInterface $cacheItem)
285286
{
286287
$data = $cacheItem->get();
287288
if (!isset($data['etag'])) {
288-
return null;
289+
return;
289290
}
290291

291292
if (is_array($data['etag'])) {
292-
foreach($data['etag'] as $etag) {
293+
foreach ($data['etag'] as $etag) {
293294
if (!empty($etag)) {
294295
return $etag;
295296
}
296297
}
297298

298-
return null;
299+
return;
299300
}
300301

301302
return $data['etag'];

0 commit comments

Comments
 (0)