diff --git a/Catalogger.Backend/Services/NewsService.cs b/Catalogger.Backend/Services/NewsService.cs index e52c783..3adfebe 100644 --- a/Catalogger.Backend/Services/NewsService.cs +++ b/Catalogger.Backend/Services/NewsService.cs @@ -34,8 +34,9 @@ public class NewsService( private readonly ILogger _logger = logger.ForContext(); private List? _messages; + private Instant _lastUpdated = Instant.MinValue; private readonly SemaphoreSlim _lock = new(1); - private bool _isExpired => clock.GetCurrentInstant() > clock.GetCurrentInstant() + ExpiresAfter; + private bool _isExpired => clock.GetCurrentInstant() > _lastUpdated + ExpiresAfter; public async Task> GetNewsAsync() { @@ -74,6 +75,7 @@ public class NewsService( } finally { + _lastUpdated = clock.GetCurrentInstant(); _lock.Release(); } }