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 } /*