m*****k 发帖数: 731 | 1 class QueryLimiter{
private long started = 0;
private int count = 0;
private int maxRate ;
public QueryLimiter(int m){
maxRate = m;
}
public boolean allowRequest(){
long now = SomeAPI.now();
if(now - started > 1000 //1sec ){
started = now;
count = 0;
}
return count
}
public void query(Object param){
count++;
//. ...query/email,whatever...
}
}
assuming this class is u... 阅读全帖 |
|