Login
网站首页 > 文章中心 > 其它

ServiceStack.Redis_使用链接池方法

作者:小编 更新时间:2023-08-12 20:27:13 浏览量:454人看过

ServiceStack.Redis_使用链接池方法-图1

①.、RedisManage.cs

public static class RedisManager
{
private static PooledRedisClientManager _prcm;

 static RedisManager()
{
CreateManager();
}

/// 
/// 
 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();
}
}

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

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

以上就是土嘎嘎小编为大家整理的ServiceStack.Redis_使用链接池方法相关主题介绍,如果您觉得小编更新的文章只要能对粉丝们有用,就是我们最大的鼓励和动力,不要忘记讲本站分享给您身边的朋友哦!!

版权声明:倡导尊重与保护知识产权。未经许可,任何人不得复制、转载、或以其他方式使用本站《原创》内容,违者将追究其法律责任。本站文章内容,部分图片来源于网络,如有侵权,请联系我们修改或者删除处理。

编辑推荐

热门文章