API访问频率限制

get ( $clientKey )) {
    $redis->set ( $clientKey, 0 );
    $redis->expire ( $clientKey, $seconds );
}

//访问频率监控
$accessCount = $redis->incr ( $clientKey );
if ($accessCount > $count) {
    echo "[WARING]:访问超过限制次数";
} else {
    $remainingTime = $redis->ttl ( $clientKey );
    echo "{$clientKey}  剩余时间:{$remainingTime}s  访问次数为:{$accessCount}";
}

你可能感兴趣的:(API访问频率限制)