Im using the Redis Throttle from Laravel for some API communications as the example:
Redis::throttle('key')
->block(0)->allow(100)->every(5)
->then(function () use ($job, $next) {
// do stuff
}, function () use ($job) {
$job->release(5);
});
}
But in other parts of the system (which are not being fully refactored right now) I need to touch the throttle (mark that I used it) without really blocking the calls.
How can I do it? Thanks.
The key is stored on redis database as a hash. If my key is named "key" it is stored on app_name_database_key and has the following format
redis:6379> HGETALL app_name_database_key
1) "start"
2) "1592994588"
3) "end"
4) "1592994688"
5) "count"
6) "12"
So it is accessible by the Redis Facade without need to tweak the prefix.
>>> Illuminate\Support\Facades\Redis::hget('key', 'count');
=> "10"
The same can be done to increment it
>>> Illuminate\Support\Facades\Redis::hincrby('key', 'count', 1);
=> 11