草庐IT

testOnBorrow

全部标签

稳,从数据库连接池 testOnBorrow 看架构设计

本文从CommonsDBCPtestOnBorrow的作用机制着手,管中窥豹,从一点去分析数据库连接池获取的过程以及架构分层设计。以下内容会按照每层的作用,贯穿分析整个调用流程。1️⃣框架层commons-poolTheindicationofwhetherobjectswillbe validatedbeforebeingborrowed fromthepool.Iftheobjectfailstovalidate,itwillbedroppedfromthepool,andwewillattempttoborrowanother.testOnBorrow不是dbcp定义的,是commons

java - 将 JedisPoolConfig testOnBorrow 设置为 false

因此,目前在我的JedisPoolConfigbean中,我将参数testOnBorrow设置为true。看起来这检索资源较慢。有一个场景,Jedis花了30分钟从Redis中检索资源(之前多次调用方法(redis.clients.jedis.BinaryJedis:exists:144和java.lang.Thread:sleep)获得资源或脱离)。我认为我可以做的是将参数testOnBorrow设置为false以防止在读取资源之前对Redis进行PING调用。所以,我的问题(我真的希望我能得到答案)是:“设置此参数会对我的应用产生什么影响”?“这个解决方案真的有效吗?”“对于这个阅