im stupid and NewsService._isExpired could literally never fire

This commit is contained in:
sam 2024-11-19 20:30:05 +01:00
parent 04d6bc958e
commit c06376dfda
Signed by: sam
GPG key ID: 5F3C3C1B3166639D

View file

@ -34,8 +34,9 @@ public class NewsService(
private readonly ILogger _logger = logger.ForContext<NewsService>();
private List<IMessage>? _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<IEnumerable<NewsMessage>> GetNewsAsync()
{
@ -74,6 +75,7 @@ public class NewsService(
}
finally
{
_lastUpdated = clock.GetCurrentInstant();
_lock.Release();
}
}