withSuspendingNonNullRedis

suspend fun <T> withSuspendingNonNullRedis(redisUrl: String = defaultRedisUrl, printStackTrace: Boolean = false, block: suspend (RedisClient) -> T): T?

Suspending variant of withNonNullRedis. Creates a short-lived connection, executes a suspending block, and closes it. Returns null if the connection fails. Connecting, pinging and closing run on Dispatchers.IO; block runs in the caller's context.

Return

the result of block, or null on connection failure

Parameters

redisUrl

the Redis connection URL

printStackTrace

if true, logs the full stack trace on connection failure

block

the suspending operation to execute with a guaranteed non-null client

Type Parameters

T

the return type of the block

Throws

if redisUrl is invalid (see RedisUtils); block is not run