Compare commits

..

No commits in common. "72f8a27272301f96c224505fa72a731e0606c909" and "a1e5006e952f30e93983f5f86411c1e937015fcf" have entirely different histories.

View File

@ -58,7 +58,6 @@ public class ResultService {
@Inject @Inject
@CacheName("club-classement") @CacheName("club-classement")
Cache cacheClubClassement; Cache cacheClubClassement;
private static final HashMap<String, Long> cacheClubClassementExp = new HashMap<>();
private static final HashMap<Long, String> combTempIds = new HashMap<>(); private static final HashMap<Long, String> combTempIds = new HashMap<>();
@ -755,10 +754,11 @@ public class ResultService {
public Uni<List<ClubClassement>> getAllClubArray(String uuid, boolean cache) { public Uni<List<ClubClassement>> getAllClubArray(String uuid, boolean cache) {
List<CardModel> cards = new java.util.ArrayList<>(); List<CardModel> cards = new java.util.ArrayList<>();
return (!cache || cacheClubClassementExp.getOrDefault(uuid, 0L) < System.currentTimeMillis() ? //noinspection unchecked
cacheClubClassement.invalidate(uuid).invoke(() -> cacheClubClassementExp.remove(uuid)) : return cacheClubClassement.invalidateIf(
Uni.createFrom().voidItem() (p) -> ((Pair<Long, List<ClubClassement>>) p).getKey() > System.currentTimeMillis())
).chain(o -> cacheClubClassement.getAsync(uuid, k -> cardRepository.list("competition.uuid = ?1", uuid) .chain(__ -> cache ? Uni.createFrom().voidItem() : cacheClubClassement.invalidate(uuid))
.chain(o -> cacheClubClassement.getAsync(uuid, k -> cardRepository.list("competition.uuid = ?1", uuid)
.invoke(__ -> System.out.println("Cache miss for club classement with uuid " + uuid)) .invoke(__ -> System.out.println("Cache miss for club classement with uuid " + uuid))
.invoke(cards::addAll) .invoke(cards::addAll)
.chain(__ -> matchRepository.list("category.compet.uuid = ?1", uuid)) .chain(__ -> matchRepository.list("category.compet.uuid = ?1", uuid))
@ -834,8 +834,8 @@ public class ResultService {
.thenComparingInt(c -> c.score[2]).reversed()) .thenComparingInt(c -> c.score[2]).reversed())
.toList(); .toList();
}) })
.invoke(__ -> cacheClubClassementExp.put(uuid, System.currentTimeMillis() + 60 * 1000L)) .map(l -> new Pair<>(System.currentTimeMillis() + 60 * 1000L, l))
)); ).map(Pair::getValue));
} }
@Data @Data