Skip to content

Commit 5f95dae

Browse files
committed
feat: ✨ update pool2 to v2.6.0 and I made the setting almost same as that of pool v1
1 parent c0a9249 commit 5f95dae

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

build.sbt

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ lazy val commonSettings: Seq[Setting[_]] = Seq(
1818
lazy val coreSettings = commonSettings ++ Seq(
1919
name := "RedisClient",
2020
libraryDependencies ++= Seq(
21-
"commons-pool" % "commons-pool" % "2.5.0",
21+
"commons-pool" % "commons-pool" % "2.6.0",
2222
"org.slf4j" % "slf4j-api" % "1.7.25",
2323
"org.slf4j" % "slf4j-log4j12" % "1.7.25" % "provided",
2424
"log4j" % "log4j" % "1.2.17" % "provided",

src/main/scala/com/redis/Pool.scala

+3-3
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@ object RedisClientPool {
3636
class RedisClientPool(val host: String, val port: Int, val maxIdle: Int = 8, val database: Int = 0, val secret: Option[Any] = None, val timeout : Int = 0,
3737
val maxConnections: Int = RedisClientPool.UNLIMITED_CONNECTIONS, val poolWaitTimeout: Long = 3000) {
3838

39-
val objectPoolConfig = new GenericObjectPoolConfig
39+
val objectPoolConfig = new GenericObjectPoolConfig[RedisClient]
4040
objectPoolConfig.setMaxIdle(maxIdle)
4141
objectPoolConfig.setMaxTotal(maxConnections)
42-
objectPoolConfig.setJmxEnabled(false)
4342
objectPoolConfig.setBlockWhenExhausted(true)
43+
objectPoolConfig.setTestOnBorrow(false)
44+
objectPoolConfig.setTestOnReturn(true)
4445

4546
val abandonedConfig = new AbandonedConfig
46-
abandonedConfig.setRemoveAbandonedOnBorrow(true)
4747
abandonedConfig.setRemoveAbandonedTimeout(TimeUnit.MILLISECONDS.toSeconds(poolWaitTimeout).toInt)
4848
val pool = new GenericObjectPool(new RedisClientFactory(host, port, database, secret, timeout), objectPoolConfig,abandonedConfig)
4949
override def toString: String = host + ":" + String.valueOf(port)

0 commit comments

Comments
 (0)