From fa9f0854b61407e07a9eb2d6af8f7bb2b65d2e28 Mon Sep 17 00:00:00 2001 From: SlayerOrnstein <6075693+SlayerOrnstein@users.noreply.github.com> Date: Sun, 17 Nov 2024 19:00:32 -0500 Subject: [PATCH] fix: invalid logic with cache invalidation --- packages/warframestat_repository/lib/src/cache_client.dart | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/warframestat_repository/lib/src/cache_client.dart b/packages/warframestat_repository/lib/src/cache_client.dart index 2073cad7b..96bbfc5ec 100644 --- a/packages/warframestat_repository/lib/src/cache_client.dart +++ b/packages/warframestat_repository/lib/src/cache_client.dart @@ -28,7 +28,6 @@ class CacheClient extends BaseClient { Future send(BaseRequest request) async { if (request.method != 'GET') return _inner.send(request); - final now = DateTime.timestamp(); final cached = cacheBox.get(request.url.toString()); if (cached != null && !cached.isExpired) { @@ -40,7 +39,7 @@ class CacheClient extends BaseClient { await cacheBox.put( request.url.toString(), - HiveCacheItem(body, now.add(cacheTime)), + HiveCacheItem(body, DateTime.timestamp().add(cacheTime)), ); return response.copy(Stream.value(body)); @@ -72,5 +71,5 @@ class HiveCacheItem extends HiveObject { @HiveField(1) final DateTime expiry; - bool get isExpired => expiry.isAfter(DateTime.timestamp()); + bool get isExpired => DateTime.timestamp().isAfter(expiry); }