fix: cache refresh v2
All checks were successful
Deploy Production Server / if_merged (pull_request) Successful in 7m13s
All checks were successful
Deploy Production Server / if_merged (pull_request) Successful in 7m13s
This commit is contained in:
parent
2d883ca1da
commit
d3805ea0e7
@ -58,6 +58,7 @@ 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<>();
|
||||||
|
|
||||||
@ -754,11 +755,10 @@ 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<>();
|
||||||
|
|
||||||
//noinspection unchecked
|
return (!cache || cacheClubClassementExp.getOrDefault(uuid, 0L) < System.currentTimeMillis() ?
|
||||||
return cacheClubClassement.invalidateIf(
|
cacheClubClassement.invalidate(uuid).invoke(() -> cacheClubClassementExp.remove(uuid)) :
|
||||||
(p) -> ((Pair<Long, List<ClubClassement>>) p).getKey() > System.currentTimeMillis())
|
Uni.createFrom().voidItem()
|
||||||
.chain(__ -> cache ? Uni.createFrom().voidItem() : cacheClubClassement.invalidate(uuid))
|
).chain(o -> cacheClubClassement.getAsync(uuid, k -> cardRepository.list("competition.uuid = ?1", 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();
|
||||||
})
|
})
|
||||||
.map(l -> new Pair<>(System.currentTimeMillis() + 60 * 1000L, l))
|
.invoke(__ -> cacheClubClassementExp.put(uuid, System.currentTimeMillis() + 60 * 1000L))
|
||||||
).map(Pair::getValue));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user