diff --git a/http-service/src/main/java/net/runelite/http/service/worlds/WorldController.java b/http-service/src/main/java/net/runelite/http/service/worlds/WorldController.java index 893ee6278d..7dba1bc1dd 100644 --- a/http-service/src/main/java/net/runelite/http/service/worlds/WorldController.java +++ b/http-service/src/main/java/net/runelite/http/service/worlds/WorldController.java @@ -24,15 +24,14 @@ */ package net.runelite.http.service.worlds; -import com.google.common.base.Suppliers; import java.io.IOException; import java.util.concurrent.TimeUnit; -import java.util.function.Supplier; import lombok.extern.slf4j.Slf4j; import net.runelite.http.api.worlds.WorldResult; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.CacheControl; import org.springframework.http.ResponseEntity; +import org.springframework.scheduling.annotation.Scheduled; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @@ -44,24 +43,19 @@ public class WorldController @Autowired private WorldsService worldsService; - private final Supplier worlds = Suppliers.memoizeWithExpiration(() -> - { - try - { - return worldsService.getWorlds(); - } - catch (IOException ex) - { - log.warn(null, ex); - throw new RuntimeException(ex); - } - }, 10, TimeUnit.MINUTES); + private WorldResult worldResult; @RequestMapping public ResponseEntity listWorlds() throws IOException { return ResponseEntity.ok() .cacheControl(CacheControl.maxAge(10, TimeUnit.MINUTES).cachePublic()) - .body(worldsService.getWorlds()); + .body(worldResult); + } + + @Scheduled(fixedDelay = 60_000L) + public void refreshWorlds() throws IOException + { + worldResult = worldsService.getWorlds(); } }