mirror of
https://github.com/codeigniter4/CodeIgniter4.git
synced 2025-02-20 11:44:28 +08:00
Merge pull request #3271 from michalsn/throttler_code_style
Throttler code style update
This commit is contained in:
commit
0ac618c37f
@ -139,7 +139,8 @@ class Throttler implements ThrottlerInterface
|
||||
$tokenName = $this->prefix . $key;
|
||||
|
||||
// Check to see if the bucket has even been created yet.
|
||||
if (($tokens = $this->cache->get($tokenName)) === null) {
|
||||
if (($tokens = $this->cache->get($tokenName)) === null)
|
||||
{
|
||||
// If it hasn't been created, then we'll set it to the maximum
|
||||
// capacity - 1, and save it to the cache.
|
||||
$this->cache->save($tokenName, $capacity - $cost, $seconds);
|
||||
@ -170,7 +171,8 @@ class Throttler implements ThrottlerInterface
|
||||
|
||||
// If $tokens >= 1, then we are safe to perform the action, but
|
||||
// we need to decrement the number of available tokens.
|
||||
if ($tokens >= 1) {
|
||||
if ($tokens >= 1)
|
||||
{
|
||||
$this->cache->save($tokenName, $tokens - $cost, $seconds);
|
||||
$this->cache->save($tokenName . 'Time', time(), $seconds);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user