From c7bc495d167a3ed247875ea35e4dae0ffeb71adf Mon Sep 17 00:00:00 2001 From: Carsten Otto Date: Thu, 25 Nov 2021 20:06:56 +0100 Subject: [PATCH] refresh channel caches --- .../java/de/cotto/lndmanagej/service/ChannelService.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/backend/src/main/java/de/cotto/lndmanagej/service/ChannelService.java b/backend/src/main/java/de/cotto/lndmanagej/service/ChannelService.java index 630d02a4..821e4779 100644 --- a/backend/src/main/java/de/cotto/lndmanagej/service/ChannelService.java +++ b/backend/src/main/java/de/cotto/lndmanagej/service/ChannelService.java @@ -24,6 +24,7 @@ import java.util.stream.Stream; @Component public class ChannelService { private static final Duration CACHE_EXPIRY = Duration.ofMinutes(1); + private static final Duration CACHE_REFRESH = Duration.ofSeconds(30); private final GrpcChannels grpcChannels; private final LoadingCache> localOpenChannelsCache; @@ -34,15 +35,19 @@ public class ChannelService { public ChannelService(GrpcChannels grpcChannels, GrpcClosedChannels grpcClosedChannels) { this.grpcChannels = grpcChannels; localOpenChannelsCache = new CacheBuilder() + .withRefresh(CACHE_REFRESH) .withExpiry(CACHE_EXPIRY) .build(grpcChannels::getChannels); closedChannelsCache = new CacheBuilder() + .withRefresh(CACHE_REFRESH) .withExpiry(CACHE_EXPIRY) .build(grpcClosedChannels::getClosedChannels); forceClosingChannelsCache = new CacheBuilder() + .withRefresh(CACHE_REFRESH) .withExpiry(CACHE_EXPIRY) .build(grpcChannels::getForceClosingChannels); waitingCloseChannelsCache = new CacheBuilder() + .withRefresh(CACHE_REFRESH) .withExpiry(CACHE_EXPIRY) .build(grpcChannels::getWaitingCloseChannels); }