Files
RedisManager/RedisManagerService.ApplyCustomConfig.cs
GuilhermeStrice f37078157d add project
2025-07-09 19:31:34 +01:00

32 lines
944 B
C#

using System;
using StackExchange.Redis;
using System.Threading.Tasks;
using RedisManager;
using RedisManager.Utils;
namespace RedisManager
{
public static class CustomConfigApplier
{
public static async Task ApplyCustomConfigAsync(InstanceConfig instance)
{
if (instance?.CustomConfig == null || instance.CustomConfig.Count == 0)
return;
try
{
var mux = RedisUtils.ConnectRedis(instance);
var db = mux.GetDatabase();
foreach (var kv in instance.CustomConfig)
{
db.Execute("CONFIG", "SET", kv.Key, kv.Value);
}
mux.Dispose();
}
catch (Exception ex)
{
Console.WriteLine($"[Daemon] Warning: Failed to apply custom config for instance '{instance.Name}': {ex.Message}");
}
}
}
}