redis Java客户端jredis连接池

我们在用jredis连接池连接redis时,连接池设置了1000以上,可是过没多久,就报无连接可用了,抛出异常。

后来网上找了些资料,在接口中发现有申请连接对象,也有释放回收对象的接口,可是,在使用过程中,我们通常只是申请对象,却忘了回收对象,就导致连接对象很快用完了。下面这边文章有对几个接口做了一些分析。

http://jiangwenfeng762.iteye.com/blog/1280700

今天想写的是,jredis的连接池是继承了apache的容器,上面那篇文章有讲到。


public void returnObject(T obj)
                  throws Exception

Returns an object instance to the pool.

If maxIdle is set to a positive value and the number of idle instances has reached this value, the returning instance is destroyed.

If testOnReturn == true, the returning instance is validated before being returned to the idle instance pool. In this case, if validation fails, the instance is destroyed.



这是apache官方文档,关于回收对象接口的一部分描述,所以大家在使用过程中主动回收对象是非常关键的。





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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值