hasFreshCache static method

Future<bool> hasFreshCache()

Check if cache exists and is valid.

Implementation

static Future<bool> hasFreshCache() async {
  try {
    final prefs = await SharedPreferences.getInstance();
    final timestamp = prefs.getInt(_podPlacesCacheTimestampKey);
    if (timestamp == null) return false;

    final cacheTime = DateTime.fromMillisecondsSinceEpoch(timestamp);
    final age = DateTime.now().difference(cacheTime);
    return age.inHours <= _maxCacheAgeHours;
  } catch (_) {
    return false;
  }
}