java redis同一时间限制同一ip登陆
public void testIpInt(){
for(int i=0;i<=20;i++){
String keyName="ip";
String now=jedis.get(keyName);
if(now!=null&&Integer.parseInt(now)>10){
System.out.println(jedis.incr(keyName));
System.out.println("不给访问");
}else{
if(now==null){
System.out.println("开始"+jedis.incr(keyName));
//秒
jedis.expire(keyName, 5);
System.out.println(jedis.dbSize());
}else{
System.out.println("计数"+jedis.incr(keyName));
//秒
jedis.expire(keyName, 5);
System.out.println(jedis.dbSize());
}
}
}
}
为什么实现不了?
求扣扣求牵手
11 years, 2 months ago