Moved to Lazy<T> and a static class for handling Redis connections with some methods to make it easier to work with JSON. Completely untested.

This commit is contained in:
barelyprofessional
2026-04-26 20:30:56 -05:00
parent 1778d0d573
commit e725ca5864
6 changed files with 128 additions and 24 deletions

View File

@@ -37,15 +37,14 @@ public class ConversationContextManager
public ConversationContextManager()
{
var connectionString = SettingsProvider.GetValueAsync(BuiltIn.Keys.BotRedisConnectionString).Result;
if (string.IsNullOrEmpty(connectionString.Value))
if (!Redis.IsAvailable)
{
Logger.Error($"Can't initialize the Nora ConversationContextManager service as Redis isn't configured in {BuiltIn.Keys.BotRedisConnectionString}");
Logger.Error($"Can't initialize the Nora ConversationContextManager service as Redis isn't configured in {BuiltIn.Keys.BotRedisConnectionString} " +
$"or the Redis client failed to connect");
throw new InvalidOperationException("Redis isn't configured");
}
var redis = ConnectionMultiplexer.Connect(connectionString.Value);
_redisDb = redis.GetDatabase();
_redisDb = Redis.Multiplexer.GetDatabase();
}
public static string GetContextKeyAsync(string mode, int userId, int roomId)