feat: make refresh interval configurable

This commit is contained in:
Stevan Freeborn
2024-08-25 17:12:26 -05:00
parent c35bcdad90
commit 4506036abf
3 changed files with 8 additions and 3 deletions
@@ -17,11 +17,14 @@ public class DatabaseWorker(
await UpdateDatabase();
using var scope = _serviceScopeFactory.CreateScope();
var dbOptions = scope.ServiceProvider.GetRequiredService<DbOptions>();
_timer = _timeProvider.CreateTimer(
callback: async _ => await UpdateDatabase(),
state: null,
dueTime: TimeSpan.FromHours(1),
period: TimeSpan.FromHours(1)
dueTime: TimeSpan.FromHours(dbOptions.RefreshIntervalInHours),
period: TimeSpan.FromHours(dbOptions.RefreshIntervalInHours)
);
}