Skip to content

Commit b369784

Browse files
authored
延期获取 cache 对象 #20
* Update Throttle.php __construct不自动注入chche * Update Throttle.php
1 parent 7171b99 commit b369784

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/Throttle.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,8 @@ class Throttle
7171
* @param Cache $cache
7272
* @param Config $config
7373
*/
74-
public function __construct(Cache $cache, Config $config)
74+
public function __construct(Config $config)
7575
{
76-
$this->cache = $cache;
7776
$this->config = array_merge(static::$default_config, $config->load('throttle', 'throttle'));
7877
}
7978

@@ -126,6 +125,8 @@ protected function allowRequest(Request $request)
126125
*/
127126
public function handle(Request $request, Closure $next)
128127
{
128+
$this->cache = app('cache');
129+
129130
$allow = $this->allowRequest($request);
130131
if (!$allow) {
131132
// 访问受限

0 commit comments

Comments
 (0)