Skip to content

Commit ad5ed80

Browse files
committed
保持 setCache 接口的有效性
1 parent b369784 commit ad5ed80

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/Throttle.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,11 @@ class Throttle
6868

6969
/**
7070
* Throttle constructor.
71-
* @param Cache $cache
7271
* @param Config $config
7372
*/
7473
public function __construct(Config $config)
7574
{
75+
$this->cache = null;
7676
$this->config = array_merge(static::$default_config, $config->load('throttle', 'throttle'));
7777
}
7878

@@ -125,8 +125,9 @@ protected function allowRequest(Request $request)
125125
*/
126126
public function handle(Request $request, Closure $next)
127127
{
128-
$this->cache = app('cache');
129-
128+
if ($this->cache == null) {
129+
$this->cache = app('cache');
130+
}
130131
$allow = $this->allowRequest($request);
131132
if (!$allow) {
132133
// 访问受限

0 commit comments

Comments
 (0)