ip 请求次数限制17

This commit is contained in:
GYJ 2025-03-24 12:20:56 +08:00
parent 0488c84143
commit da9db2f8b1
1 changed files with 3 additions and 0 deletions

View File

@ -65,6 +65,9 @@ public class IpAccessCounter {
Set<String> removedIps = new HashSet<>();
for (Map.Entry<String, List<Long>> entry : IP_ACCESS_TIMES.entrySet()) {
List<Long> accessTimes = entry.getValue();
if (accessTimes == null || accessTimes.isEmpty()) {
continue;
}
accessTimes.removeIf(time -> currentTime - time > ONE_MINUTE);
if (accessTimes.isEmpty()) {
removedIps.add(entry.getKey());