...
|
...
|
@@ -22,6 +22,7 @@ public class PersionalRateLimitService { |
|
|
private Map<String, Integer> oldCountMap = new ConcurrentHashMap<String, Integer>();
|
|
|
|
|
|
public boolean isPersionalRateLimit(String rateLimitName, PersionalRateLimitConfig limitConfig) {
|
|
|
try {
|
|
|
long expireTime = System.currentTimeMillis() + limitConfig.getSecond() * 1000L;
|
|
|
KeyCountWithExpiredTime keyCountWithExpiredTime = keyCountMap.putIfAbsent(rateLimitName, new KeyCountWithExpiredTime(expireTime));
|
|
|
if (keyCountWithExpiredTime == null) {
|
...
|
...
|
@@ -38,6 +39,10 @@ public class PersionalRateLimitService { |
|
|
oldCountMap.put(rateLimitName, currentCount);
|
|
|
DOWNGRADE.error("PersionalRateLimit happen ,rateLimitName is [{}],currentCount is[{}], limitConfig is [{}]", rateLimitName,currentCount, limitConfig.toLogInfo());
|
|
|
return true;
|
|
|
}catch (Exception e){
|
|
|
DOWNGRADE.error(e.getMessage(),e);
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
} |
...
|
...
|
|