ManaPHP\Security\RateLimiter\Adapter\Redis::_limit PHP Method

_limit() protected method

protected _limit ( string $id, string $resource, integer $duration, integer $times ) : boolean
$id string
$resource string
$duration integer
$times integer
return boolean
    protected function _limit($id, $resource, $duration, $times)
    {
        $key = $this->_prefix . $id . ':' . $resource;
        $current_times = $this->redis->incr($key);
        if ($current_times === 1) {
            $this->redis->setTimeout($key, $duration);
        }
        return $times >= $current_times;
    }