newRedisClient

fun newRedisClient(redisUrl: String = defaultRedisUrl, maxPoolSize: Int = System.getProperty(REDIS_MAX_POOL_SIZE)?.toInt() ?: 10, maxIdleSize: Int = System.getProperty(REDIS_MAX_IDLE_SIZE)?.toInt() ?: 5, minIdleSize: Int = System.getProperty(REDIS_MIN_IDLE_SIZE)?.toInt() ?: 1, maxWaitSecs: Long = System.getProperty(REDIS_MAX_WAIT_SECS)?.toLong() ?: 1L): RedisClient

Creates a new pooled RedisClient with the given configuration.

Each pool parameter defaults to its system property (see REDIS_MAX_POOL_SIZE, etc.) if set, otherwise to the concrete fallback noted below. The connection and socket timeouts both use Jedis' DEFAULT_TIMEOUT.

Connections are validated when they are borrowed and while they sit idle, but not when they are returned, which would add a second round-trip to every command.

Return

a configured RedisClient with connection pooling

Parameters

redisUrl

the Redis connection URL (defaults to the REDIS_URL environment variable)

maxPoolSize

maximum connections in the pool, or UNLIMITED_POOL_SIZE for no limit; defaults to the REDIS_MAX_POOL_SIZE property or 10

maxIdleSize

maximum idle connections, or UNLIMITED_POOL_SIZE for no limit; defaults to the REDIS_MAX_IDLE_SIZE property or 5

minIdleSize

minimum idle connections; defaults to the REDIS_MIN_IDLE_SIZE property or 1. A value above maxIdleSize is lowered to it (commons-pool2 does so), and a warning is logged

maxWaitSecs

seconds to wait when borrowing a connection; defaults to the REDIS_MAX_WAIT_SECS property or 1

Throws

if a pool setting is negative (other than UNLIMITED_POOL_SIZE for maxPoolSize and maxIdleSize), if maxPoolSize is 0, which would create a pool that can never lend a connection, or if redisUrl is invalid (see RedisUtils)