java jedis 切片连接池_jedis连接池配置详解jedisPoolConfig

我也是参考其他博主的:比如:https://www.cnblogs.com/hujihon/p/5313731.html下面是我自己看的一些源码+个人理解:maxTotal:默认值8解释:在指定时刻通过pool能够获取到的最大的连接的jedis个数getMaxTotal():Returns the maximum number of objects that can be allocated 分配...
摘要由CSDN通过智能技术生成

我也是参考其他博主的:

比如:

https://www.cnblogs.com/hujihon/p/5313731.html

下面是我自己看的一些源码+个人理解:

maxTotal:默认值8

解释:在指定时刻通过pool能够获取到的最大的连接的jedis个数

getMaxTotal():

Returns the maximum number of objects that can be allocated 分配指派 by the pool (checked out to clients, or idle awaiting checkout) at a given time. When negative, there is no limit to the number of objects that can be managed by the pool at one time.

Returns:the cap on the total number of object instances managed by the pool.

个人理解,在获取当时通过pool能够获取到的最大的连接的jedis个数(已经被客户端 连接上或者正在闲置等待客户端连接)

举例:

当我设置时,如果

for(int i=0;i<15;i++){

Jedis resource = jedisSentinelPool.getResource();

System.out.println(resource);

//resource.close();

}

如果没有close的话,只取到了10个连接:会报错:

0aedb9c6046a6a104604e632770847b9.png

报错截图:

8f29a1d2611fc9f792e06de43eb912cc.png

当把resource.close();放开后:

没报错,每次都是取到一个对象:

02a011b2ef2382e8d08192fbf0f9e2a7.png

maxIdle:默认值8

最大能够保持idle的数量,控制一个pool最多有多少个状态为idle的jedis实例

/*** Returns the cap on the number of "idle" instances in the pool. If maxIdle

* is set too low on heavily loaded systems it is possible you will see

* objects being destroyed and almost immediately new objects being created.

* This is a result of the active threads momentarily returning objects

* faster than they are requesting them them, causing the number of idle

* objects to rise above maxIdle. The best value for maxIdle for heavily

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值