Skip to content

Commit 96f1cec

Browse files
committed
优化代码
1 parent 7527bac commit 96f1cec

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

src/Middleware/CacheResponse.php

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,19 @@ protected function getResponseCache($request, $next, $minutes)
6565
{
6666
$this->cache_key = $key = $this->resolveRequestKey($request);
6767

68-
$responseCache = Cache::remember($key, $resolveMinutes = $this->resolveMinutes($minutes), function () use ($request, $next, $resolveMinutes) {
69-
$this->cacheMissed();
70-
71-
$response = $next($request);
72-
73-
return $this->resolveResponseCache($response) + [
74-
'cacheExpireAt' => Carbon::now()->addMinutes($resolveMinutes)->format('Y-m-d\TH:i:s')
75-
];
76-
});
68+
$responseCache = Cache::remember(
69+
$key,
70+
$resolveMinutes = $this->resolveMinutes($minutes),
71+
function () use ($request, $next, $resolveMinutes) {
72+
$this->cacheMissed();
73+
74+
$response = $next($request);
75+
76+
return $this->resolveResponseCache($response) + [
77+
'cacheExpireAt' => Carbon::now()->addMinutes($resolveMinutes)->format('Y-m-d\TH:i:s')
78+
];
79+
}
80+
);
7781

7882
$this->cache_expire_at = $responseCache['cacheExpireAt'];
7983

0 commit comments

Comments
 (0)