|  | @ -30,6 +30,7 @@ public class RedisRateLimitStorage extends AbstractRateLimitStorage {
 | 
	
		
			
				|  |  |     private Logger logger = LoggerFactory.getLogger(RedisRateLimitStorage.class);
 | 
	
		
			
				|  |  |     private static String redisPre = "router:rateLimit:";
 | 
	
		
			
				|  |  |     private static String redisPreCount = "router:rateLimitCount:";
 | 
	
		
			
				|  |  |     private static String and = ":";
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     private StringRedisTemplate redisTemplate;
 | 
	
		
			
				|  |  | 
 | 
	
	
		
			
				|  | @ -101,10 +102,10 @@ public class RedisRateLimitStorage extends AbstractRateLimitStorage {
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     @Override
 | 
	
		
			
				|  |  |     public Boolean countDec(String id) {
 | 
	
		
			
				|  |  |     public Boolean countDec(String id, String requestIP) {
 | 
	
		
			
				|  |  |         SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
 | 
	
		
			
				|  |  |         try {
 | 
	
		
			
				|  |  |             String key = redisPreCount + id;
 | 
	
		
			
				|  |  |             String key = redisPreCount + id + and + requestIP;
 | 
	
		
			
				|  |  |             if (redisTemplate.hasKey(key)) {
 | 
	
		
			
				|  |  |                 redisTemplate.watch(key);
 | 
	
		
			
				|  |  |                 String value = redisTemplate.opsForValue().get(key);
 | 
	
	
		
			
				|  | @ -122,7 +123,7 @@ public class RedisRateLimitStorage extends AbstractRateLimitStorage {
 | 
	
		
			
				|  |  |                                 Date endTime = simpleDateFormat.parse(rateLimitCount.getEndTime());
 | 
	
		
			
				|  |  |                                 if (new Date().after(endTime)) {
 | 
	
		
			
				|  |  |                                     redisTemplate.delete(key);
 | 
	
		
			
				|  |  |                                 }else{
 | 
	
		
			
				|  |  |                                 } else {
 | 
	
		
			
				|  |  |                                     redisTemplate.expireAt(key, endTime);
 | 
	
		
			
				|  |  |                                 }
 | 
	
		
			
				|  |  |                             } catch (ParseException e) {
 | 
	
	
		
			
				|  | @ -160,16 +161,16 @@ public class RedisRateLimitStorage extends AbstractRateLimitStorage {
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     @Override
 | 
	
		
			
				|  |  |     public Integer getCount(String id) {
 | 
	
		
			
				|  |  |     public Integer getCount(String id, String requestIp) {
 | 
	
		
			
				|  |  |         SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
 | 
	
		
			
				|  |  |         String key = redisPreCount + id;
 | 
	
		
			
				|  |  |         String key = redisPreCount + id + and + requestIp;
 | 
	
		
			
				|  |  |         String value = redisTemplate.opsForValue().get(key);
 | 
	
		
			
				|  |  |         RateLimitCount rateLimitCount = JSON.parseObject(value, RateLimitCount.class);
 | 
	
		
			
				|  |  |         try {
 | 
	
		
			
				|  |  |             Date endTime = simpleDateFormat.parse(rateLimitCount.getEndTime());
 | 
	
		
			
				|  |  |             if (new Date().after(endTime)) {
 | 
	
		
			
				|  |  |                 redisTemplate.delete(key);
 | 
	
		
			
				|  |  |             }else{
 | 
	
		
			
				|  |  |             } else {
 | 
	
		
			
				|  |  |                 redisTemplate.expireAt(key, endTime);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         } catch (ParseException e) {
 | 
	
	
		
			
				|  | @ -183,13 +184,13 @@ public class RedisRateLimitStorage extends AbstractRateLimitStorage {
 | 
	
		
			
				|  |  |      * @return true 返回时已经达到上限 false表示没有
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     @Override
 | 
	
		
			
				|  |  |     public Boolean isUpperLimit(String id) {
 | 
	
		
			
				|  |  |     public Boolean isUpperLimit(String id, String requestIp) {
 | 
	
		
			
				|  |  |         //不存在key的时候默认是可以的
 | 
	
		
			
				|  |  |         String key = redisPreCount + id;
 | 
	
		
			
				|  |  |         String key = redisPreCount + id + and + requestIp;
 | 
	
		
			
				|  |  |         if (!redisTemplate.hasKey(key)) {
 | 
	
		
			
				|  |  |             return false;
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         return getCount(id) == 0 ? true : false;
 | 
	
		
			
				|  |  |         return getCount(id,requestIp) == 0 ? true : false;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     public StringRedisTemplate getRedisTemplate() {
 |