add project
This commit is contained in:
31
RedisManagerService.ApplyCustomConfig.cs
Normal file
31
RedisManagerService.ApplyCustomConfig.cs
Normal file
@ -0,0 +1,31 @@
|
||||
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}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user