mirror of
https://github.com/Sheldan/abstracto.git
synced 2026-09-12 01:58:00 +00:00
[AB-xxx] adding unit test and improvement for runtime experience storage
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package dev.sheldan.abstracto.experience.service;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import lombok.Getter;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@@ -38,6 +40,7 @@ public class RunTimeExperienceService {
|
||||
|
||||
public void cleanupRunTimeStorage() {
|
||||
Instant now = Instant.now();
|
||||
Set<Long> serverIdsToRemove = new HashSet<>();
|
||||
runtimeExperience.forEach((serverId, userInstantMap) -> {
|
||||
List<Long> userIdsToRemove = new ArrayList<>();
|
||||
userInstantMap.forEach((userId, instant) -> {
|
||||
@@ -46,6 +49,10 @@ public class RunTimeExperienceService {
|
||||
}
|
||||
});
|
||||
userIdsToRemove.forEach(userInstantMap::remove);
|
||||
if(userInstantMap.isEmpty()) {
|
||||
serverIdsToRemove.add(serverId);
|
||||
}
|
||||
});
|
||||
serverIdsToRemove.forEach(runtimeExperience::remove);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user