You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.7 KiB
C#

using ServiceStack.Redis;
namespace Txgy.RBS.Framework.RedisHelper.Init
{
/// <summary>
/// Redis管理中心 创建Redis链接
/// </summary>
public class RedisManager
{
/// <summary>
/// redis配置文件信息
/// </summary>
private static RedisConfigInfo RedisConfigInfo = new RedisConfigInfo();
/// <summary>
/// Redis客户端池化管理
/// </summary>
private static PooledRedisClientManager prcManager;
/// <summary>
/// 静态构造方法,初始化链接池管理对象
/// </summary>
static RedisManager()
{
CreateManager();
}
/// <summary>
/// 创建链接池管理对象
/// </summary>
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
});
}
/// <summary>
/// 客户端缓存操作对象
/// </summary>
public static IRedisClient GetClient(RedisConfigInfo configInfo)
{
return prcManager.GetClient();
}
}
}