withRedisPool

fun <T> RedisClient.withRedisPool(printStackTrace: Boolean = false, block: (RedisClient?) -> T): T

Executes block with this RedisClient, passing null if the connection fails.

Extension function on RedisClient. Pings the server first to verify connectivity.

Return

the result of block

Parameters

printStackTrace

if true, logs the full stack trace on connection failure

block

the operation to execute; receives null on connection failure

Type Parameters

T

the return type of the block