1、RedisManage.cs

public static class RedisManager
{
	private static PooledRedisClientManager _prcm;

 	static RedisManager()
	{
		CreateManager();
	}

    /// <summary>
    /// 创建链接池管理对象
    /// </summary>
 	private static void CreateManager()
	{	
		_prcm = new PooledRedisClientManager(writeServerList, readServerList,
					new RedisClientManagerConfig
					{
						/*Config*/
					});
	}
	public static IRedisClient GetClient()
	{
		if (_prcm == null)
		{
			CreateManager();
		}
		return _prcm.GetClient();
	}

	public static IRedisClient GetReadOnlyClient()
	{
		if (_prcm == null)
		{
			CreateManager();
		}
		return _prcm.GetReadOnlyClient();
	}
}

2、调用

using(var client = RedisManage.GetClient())
{
	/*content*/
}

using(var client = RedisManage.GetReadOnlyClient())
{
	/*content*/
}

相关文章:

  • 2022-12-23
  • 2021-10-15
  • 2021-07-02
  • 2022-12-23
  • 2021-12-05
猜你喜欢
  • 2022-03-01
  • 2021-06-15
  • 2021-12-09
  • 2021-12-18
  • 2022-12-23
  • 2022-02-21
  • 2022-12-23
相关资源
相似解决方案