public function limitAny($resource, $duration, $ip_times, $user_times = null)
{
$userId = $this->userIdentity->getId();
if ($userId) {
$id = $userId;
$times = $user_times ?: $ip_times;
} else {
$id = $this->request->getClientAddress();
$times = $ip_times;
}
if (!$this->_limit($id, $this->dispatcher->getModuleName() . ':' . $resource, $duration, $times)) {
throw new RateLimiterException('rate limit is exceed.', ['resource' => $resource, 'duration' => $duration, 'ip_times' => $ip_times, 'user_times' => $user_times]);
}
}