im stupid and NewsService._isExpired could literally never fire
This commit is contained in:
parent
04d6bc958e
commit
c06376dfda
1 changed files with 3 additions and 1 deletions
|
|
@ -34,8 +34,9 @@ public class NewsService(
|
||||||
|
|
||||||
private readonly ILogger _logger = logger.ForContext<NewsService>();
|
private readonly ILogger _logger = logger.ForContext<NewsService>();
|
||||||
private List<IMessage>? _messages;
|
private List<IMessage>? _messages;
|
||||||
|
private Instant _lastUpdated = Instant.MinValue;
|
||||||
private readonly SemaphoreSlim _lock = new(1);
|
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()
|
public async Task<IEnumerable<NewsMessage>> GetNewsAsync()
|
||||||
{
|
{
|
||||||
|
|
@ -74,6 +75,7 @@ public class NewsService(
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
_lastUpdated = clock.GetCurrentInstant();
|
||||||
_lock.Release();
|
_lock.Release();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue