我在我的站点上使用laravel 8,我使用Illuminate\Support\Facades\RateLimiter来定义我的自定义节流阀示例如下
RateLimiter::for('stop', function (Request $request) {
$ip = $request->ip();
$maxAttempts = 5;
$limit = Limit::perMinutes((60 * 24), $maxAttempts)->by('stop_'.$ip);
return $limit;
});
我想清除这个限制,所以我使用
app(\Illuminate\Cache\RateLimiter::class)->clear('stop_'.$request->ip());
还有这个代码
app(\Illuminate\Cache\RateLimiter::class)->resetAttempts('stop_'.$request->ip());
但这些都不会工作后,重新加载页面仍然显示429错误我想清除限制在某些条件下,但我似乎不能使这项工作如何才能清除限制,而不等待计时器?我想将其设置为24小时,但应该能够允许用户重置它时,正确验证.
2条答案
按热度按时间8yparm6h1#
我对代码进行了深入研究,发现密钥在存储该高速缓存之前进行了散列,但当直接发送clear方法时,散列并不包含在其中,因此clear应该是:
对于我的代码应该是
eivgtgni2#
或