using CSRedis;
using dodohold.core;


namespace molilian.core
{
    public class RedisClientManager
    {
        private static Dictionary<string, CSRedisClient> redisClients = [];

        public static CSRedisClient GetRedisClient(string connectionString)
        {
            if (!redisClients.ContainsKey(connectionString))
            {
                var redisClient = new CSRedisClient(connectionString);
                redisClients[connectionString] = redisClient;
            }

            return redisClients[connectionString];
        }


        // 可选：释放 Redis 客户端资源
        public static void DisposeRedisClients()
        {
            foreach (var client in redisClients.Values)
            {
                client.Dispose();
            }
            redisClients.Clear();
        }
    }
}
