From 83c12599c7d51b54d386f412b43ce9e94d9eb57d Mon Sep 17 00:00:00 2001 From: Martin Eyben Date: Fri, 20 Dec 2024 11:15:34 +0100 Subject: [PATCH] fix: cache warnings --- .../eirb/pg203/weather/data/api/WeatherDataCache.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/eirb/pg203/weather/data/api/WeatherDataCache.java b/src/main/java/eirb/pg203/weather/data/api/WeatherDataCache.java index 23309c8..88381b7 100644 --- a/src/main/java/eirb/pg203/weather/data/api/WeatherDataCache.java +++ b/src/main/java/eirb/pg203/weather/data/api/WeatherDataCache.java @@ -12,9 +12,9 @@ import org.json.JSONObject; public class WeatherDataCache { private static class CacheValue { - private WeatherData value; - private int day; - private Instant timestamp; + private final WeatherData value; + private final int day; + private final Instant timestamp; CacheValue(WeatherData value, int day, Instant timestamp) { this.value = value; @@ -61,7 +61,7 @@ public class WeatherDataCache { } private HashMap cache = new HashMap<>(); - private long cacheTTL = 3600; // Cache data Time To Live in sec + private static final long cacheTTL = 3600; // Cache data Time To Live in sec private String makeKey(String cityName, int day) { return String.format(Locale.ENGLISH, "%s%d", cityName, day); @@ -87,7 +87,7 @@ public class WeatherDataCache { long dt = Instant.now().getEpochSecond() - cacheValue.getTimestamp().getEpochSecond(); - return dt > this.cacheTTL; // if older than TTL, needs update + return dt > cacheTTL; // if older than TTL, needs update } /*