fix: cache warnings

This commit is contained in:
Martin Eyben 2024-12-20 11:15:34 +01:00
parent 61a459ce78
commit 83c12599c7

View File

@ -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<String, CacheValue> 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
}
/*