Skip to content

Commit

Permalink
feat: ✨ update pool2 to v2.6.0 and I made the setting almost same as …
Browse files Browse the repository at this point in the history
…that of pool v1
  • Loading branch information
masahitojp committed Oct 29, 2018
1 parent c0a9249 commit 5f95dae
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ lazy val commonSettings: Seq[Setting[_]] = Seq(
lazy val coreSettings = commonSettings ++ Seq(
name := "RedisClient",
libraryDependencies ++= Seq(
"commons-pool" % "commons-pool" % "2.5.0",
"commons-pool" % "commons-pool" % "2.6.0",
"org.slf4j" % "slf4j-api" % "1.7.25",
"org.slf4j" % "slf4j-log4j12" % "1.7.25" % "provided",
"log4j" % "log4j" % "1.2.17" % "provided",
Expand Down
6 changes: 3 additions & 3 deletions src/main/scala/com/redis/Pool.scala
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ object RedisClientPool {
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,
val maxConnections: Int = RedisClientPool.UNLIMITED_CONNECTIONS, val poolWaitTimeout: Long = 3000) {

val objectPoolConfig = new GenericObjectPoolConfig
val objectPoolConfig = new GenericObjectPoolConfig[RedisClient]
objectPoolConfig.setMaxIdle(maxIdle)
objectPoolConfig.setMaxTotal(maxConnections)
objectPoolConfig.setJmxEnabled(false)
objectPoolConfig.setBlockWhenExhausted(true)
objectPoolConfig.setTestOnBorrow(false)
objectPoolConfig.setTestOnReturn(true)

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

0 comments on commit 5f95dae

Please sign in to comment.