一个 RecentCounter 类来计算特定时间范围内最近的请求。
var RecentCounter = function () {
this.times = [];
};
RecentCounter.prototype.ping = function (t) {
this.times.push(t);
while (this.times[0] < t - 3000) {
this.times.shift();
}
return this.times.length;
};