using ServiceStack.Redis;
namespace Txgy.RBS.Framework.RedisHelper.Init
{
///
/// Redis管理中心 创建Redis链接
///
public class RedisManager
{
///
/// redis配置文件信息
///
private static RedisConfigInfo RedisConfigInfo = new RedisConfigInfo();
///
/// Redis客户端池化管理
///
private static PooledRedisClientManager prcManager;
///
/// 静态构造方法,初始化链接池管理对象
///
static RedisManager()
{
CreateManager();
}
///
/// 创建链接池管理对象
///
private static void CreateManager()
{
string[] WriteServerConStr = RedisConfigInfo.WriteServerList.Split(',');
string[] ReadServerConStr = RedisConfigInfo.ReadServerList.Split(',');
prcManager = new PooledRedisClientManager(ReadServerConStr, WriteServerConStr,
new RedisClientManagerConfig
{
MaxWritePoolSize = RedisConfigInfo.MaxWritePoolSize,
MaxReadPoolSize = RedisConfigInfo.MaxReadPoolSize,
AutoStart = RedisConfigInfo.AutoStart,
DefaultDb=2
});
}
///
/// 客户端缓存操作对象
///
public static IRedisClient GetClient(RedisConfigInfo configInfo)
{
return prcManager.GetClient();
}
}
}