diff --git a/system/routing/throttle.php b/system/routing/throttle.php index ad824dba..1f862a9d 100644 --- a/system/routing/throttle.php +++ b/system/routing/throttle.php @@ -30,8 +30,9 @@ public static function check($max_attempts, $decay_minutes = 1) $decay_minutes = (int) $decay_minutes; $decay_minutes = ($decay_minutes < 1) ? 1 : $decay_minutes; $key = static::key(); + $data = Cache::get($key); - if (!Cache::has($key)) { + if (!$data) { $data = [ 'limit' => $max_attempts, 'remaining' => $max_attempts, @@ -40,12 +41,9 @@ public static function check($max_attempts, $decay_minutes = 1) 'key' => $key, 'ip' => Request::ip(), ]; - Cache::put($key, $data, $decay_minutes); } - $data = Cache::get($key); - if ($data['remaining'] > 0) { $data['remaining'] = $data['remaining'] - 1; Cache::put($key, $data, $decay_minutes);