Skip to content

Commit 1b9e3ad

Browse files
committed
document custom rate limiter increment
1 parent 5fd264c commit 1b9e3ad

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

rate-limiting.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,20 +66,24 @@ If you would like to manually interact with the rate limiter, a variety of other
6666
return 'Too many attempts!';
6767
}
6868

69-
RateLimiter::hit('send-message:'.$user->id);
69+
RateLimiter::increment('send-message:'.$user->id);
7070

7171
// Send message...
7272

73-
Alternatively, you may use the `remaining` method to retrieve the number of attempts remaining for a given key. If a given key has retries remaining, you may invoke the `hit` method to increment the number of total attempts:
73+
Alternatively, you may use the `remaining` method to retrieve the number of attempts remaining for a given key. If a given key has retries remaining, you may invoke the `increment` method to increment the number of total attempts:
7474

7575
use Illuminate\Support\Facades\RateLimiter;
7676

7777
if (RateLimiter::remaining('send-message:'.$user->id, $perMinute = 5)) {
78-
RateLimiter::hit('send-message:'.$user->id);
78+
RateLimiter::increment('send-message:'.$user->id);
7979

8080
// Send message...
8181
}
8282

83+
If you would like to increment the value for a given rate limiter key by more than one, you may provide the desired amount to the `increment` method:
84+
85+
RateLimiter::increment('send-message:'.$user->id, amount: 5);
86+
8387
<a name="determining-limiter-availability"></a>
8488
#### Determining Limiter Availability
8589

@@ -93,7 +97,7 @@ When a key has no more attempts left, the `availableIn` method returns the numbe
9397
return 'You may try again in '.$seconds.' seconds.';
9498
}
9599

96-
RateLimiter::hit('send-message:'.$user->id);
100+
RateLimiter::increment('send-message:'.$user->id);
97101

98102
// Send message...
99103

0 commit comments

Comments
 (0)