imj / frequency
A simple frequency control system based on redis
v1.0.3
2017-01-12 12:20 UTC
Requires
- php: >=5.3.0
Requires (Dev)
- phpunit/phpunit: ~4.3.0
This package is not auto-updated.
Last update: 2024-10-26 20:20:42 UTC
README
Installation
composer require imj/frequency
Basic Usage
use Imj\Frequency; $config = [ 'time_unit' => 5, 'recycle' => 120, 'default' => 0, 'rules' => [ 10 => [ 10 => 1, // 10分钟操作10次及以上返回1 20 => 2, 30 => 3, 40 => 4, ], 20 => [ 80 => 5 ] ] ]; $redis = getRedis(); $freq = new Frequency($redis, $config); $ip = getIp(); $ret= $freq->check($ip); $min = 10; $times = $freq->checkTimes($ip, $min);
License
licensed under the MIT License - see the LICENSE
file for details