From 08ba5dd561ce50f4a58f79316bb84980dae61b89 Mon Sep 17 00:00:00 2001 From: Albie Spriddell Date: Sun, 1 Dec 2024 12:25:44 +0000 Subject: [PATCH] fix bad db version key --- DragonFruit.OnionFruit.Web.Worker/Worker.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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)