diff --git a/DragonFruit.OnionFruit.Web.Worker/Worker.cs b/DragonFruit.OnionFruit.Web.Worker/Worker.cs index 49ec920..af3a9d3 100644 --- a/DragonFruit.OnionFruit.Web.Worker/Worker.cs +++ b/DragonFruit.OnionFruit.Web.Worker/Worker.cs @@ -52,10 +52,13 @@ private async Task PerformUpdate() var sourceInstances = new Dictionary(); var redis = scope.ServiceProvider.GetRequiredService().GetDatabase(); + var keyPrefix = _config[RedisClientConfigurator.PrefixConfigKey] ?? RedisClientConfigurator.DefaultKeyPrefix; + + var databaseVersionKey = new RedisKey($"{keyPrefix}:{LastDatabaseVersionKey}"); var nextVersion = DateTimeOffset.UtcNow.ToUnixTimeSeconds(); #if !DEBUG - var lastUpdatedValue = await redis.StringGetAsync(LastDatabaseVersionKey).ConfigureAwait(false); + var lastUpdatedValue = await redis.StringGetAsync(databaseVersionKey).ConfigureAwait(false); var lastVersion = DateTimeOffset.FromUnixTimeSeconds(lastUpdatedValue.HasValue && long.TryParse(lastUpdatedValue.ToString(), out var val) ? val : 0); #else // in debug mode, use minvalue to always perform fetch. @@ -138,8 +141,7 @@ private async Task PerformUpdate() _stopwatch.Stop(); _logger.LogInformation("Worker update completed successfully (took {ts})", _stopwatch.Elapsed); - var redisPrefix = _config[RedisClientConfigurator.PrefixConfigKey] ?? RedisClientConfigurator.DefaultKeyPrefix; - await redis.StringSetAsync($"{redisPrefix}:{LastDatabaseVersionKey}", nextVersion, TimeSpan.FromDays(1)).ConfigureAwait(false); + await redis.StringSetAsync(databaseVersionKey, nextVersion, TimeSpan.FromDays(1)).ConfigureAwait(false); } private List GetDescriptors(IConfiguration config)