@Test public void test2() throws InterruptedException { JedisPool jp=new JedisPool("127.0.0.1",6379); LimitRule limitRule=new LimitRule(); limitRule.setSeconds(1); limitRule.setLimitCount(5); limitRule.setLockCount(7); limitRule.setLockTime(2); AccessSpeedLimit accessSpeedLimit=new AccessSpeedLimit(jp); SimpleDateFormat sdf=new SimpleDateFormat(" mm:ss"); while(true){ if(accessSpeedLimit.tryAccess("10.0.0.1",limitRule)){ System.out.println("yes"+sdf.format(new Date())); }else{ System.out.println("no"+sdf.format(new Date())); } Thread.sleep(100); } }
public boolean tryAccess(String key, int seconds, int limitCount) { LimitRule limitRule = new LimitRule(); limitRule.setLimitCount(limitCount); limitRule.setSeconds(seconds); return tryAccess(key, limitRule); }
AccessSpeedLimit { public boolean tryAccess(String key, int seconds, int limitCount) { LimitRule limitRule = new LimitRule(); limitRule.setLimitCount(limitCount); limitRule.setSeconds(seconds); return tryAccess(key, limitRule); } }
AccessSpeedLimit { public boolean tryAccess(String key, int seconds, int limitCount) { LimitRule limitRule = new LimitRule(); limitRule.setLimitCount(limitCount); limitRule.setSeconds(seconds); return tryAccess(key, limitRule); } AccessSpeedLimit();  AccessSpeedLimit(JedisPool jedisPool); }
AccessSpeedLimit { public boolean tryAccess(String key, int seconds, int limitCount) { LimitRule limitRule = new LimitRule(); limitRule.setLimitCount(limitCount); limitRule.setSeconds(seconds); return tryAccess(key, limitRule); } AccessSpeedLimit();  AccessSpeedLimit(JedisPool jedisPool); JedisPool getJedisPool(); void setJedisPool(JedisPool jedisPool); boolean tryAccess(String key, int seconds, int limitCount); boolean tryAccess(String key, LimitRule limitRule); }
AccessSpeedLimit { public boolean tryAccess(String key, int seconds, int limitCount) { LimitRule limitRule = new LimitRule(); limitRule.setLimitCount(limitCount); limitRule.setSeconds(seconds); return tryAccess(key, limitRule); } AccessSpeedLimit();  AccessSpeedLimit(JedisPool jedisPool); JedisPool getJedisPool(); void setJedisPool(JedisPool jedisPool); boolean tryAccess(String key, int seconds, int limitCount); boolean tryAccess(String key, LimitRule limitRule);  }