using CSRedis;
using System.Collections.Concurrent;
using System.Linq;
namespace Fuel.Infrastructure
{
///
/// redis 多个database 客户端
///
public class CoreRedisHelper
{
public static ConcurrentDictionary redisHelpers
{
get;
private set;
}
public static bool AddClient(string clientName, CSRedisClient redisHelper)
{
if (redisHelpers == null)
{
redisHelpers = new ConcurrentDictionary();
}
if (string.IsNullOrWhiteSpace(clientName))
{
return false;
}
return redisHelpers.TryAdd(clientName, redisHelper);
}
///
/// 获取redis客户端名称
///
///
///
public static CSRedisClient GetRedisHelper(string clientName)
{
if (redisHelpers.Any())
{
if (redisHelpers.Keys.Any(p => p == clientName))
{
return redisHelpers[clientName];
}
}
return null;
}
}
}