RecoverableJedisPool

Encapsulation of JedisPool which supports AutoCloseable semantics for Jedis instance operations and connection pool recovery (e.g. when all connections of the pool cannot be used).

All methods in this class is thread-safe.

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard

Whether the JedisPool is closed.

Link copied to clipboard

ReentrantReadWriteLock guarding mutual exclusion of the pool.

Link copied to clipboard
private var pool: JedisPool

JedisPool backing this instance.

Functions

Link copied to clipboard
open override fun close()
Link copied to clipboard
private fun createJedisPool(): JedisPool

Creates a JedisPool using the current, active configuration.

Link copied to clipboard
private fun recreatePool(): JedisPool?

Recreates the Jedis connection pool.

Link copied to clipboard
fun resetPool()

Resets the current pool by invoking AutoCloseable.close on the pool, then recreating the pool using the currently active configuration.

Link copied to clipboard
suspend fun resetPoolSuspend()

Similar to resetPool, but closes the old pool in a coroutine to avoid blocking the executing thread.

Link copied to clipboard
fun <T> useConnection(block: (Jedis) -> T): T

Obtains a Jedis instance from the pool, executes block, and closes the connection at the end.

Link copied to clipboard
suspend fun <T> useConnectionSuspend(context: CoroutineContext = Dispatchers.IO, block: suspend (Jedis) -> T): T

Similar to useConnection, but executes block in a coroutine context.