Skip to content

Commit

Permalink
fix: invalid logic with cache invalidation
Browse files Browse the repository at this point in the history
  • Loading branch information
SlayerOrnstein committed Nov 18, 2024
1 parent af0ee09 commit fa9f085
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions packages/warframestat_repository/lib/src/cache_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ class CacheClient extends BaseClient {
Future<StreamedResponse> 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) {
Expand All @@ -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));
Expand Down Expand Up @@ -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);
}

0 comments on commit fa9f085

Please sign in to comment.