public class JedisConnectionFactory extends Object implements InitializingBean, DisposableBean, RedisConnectionFactory
| Constructor and Description |
|---|
JedisConnectionFactory()
Constructs a new
JedisConnectionFactory instance with default settings (default connection pooling, no
shard information). |
JedisConnectionFactory(redis.clients.jedis.JedisPoolConfig poolConfig)
Constructs a new
JedisConnectionFactory instance using the given pool configuration. |
JedisConnectionFactory(redis.clients.jedis.JedisShardInfo shardInfo)
Constructs a new
JedisConnectionFactory instance. |
JedisConnectionFactory(RedisSentinelConfiguration sentinelConfig)
Constructs a new
JedisConnectionFactory instance using the given JedisPoolConfig applied to
JedisSentinelPool. |
JedisConnectionFactory(RedisSentinelConfiguration sentinelConfig,
redis.clients.jedis.JedisPoolConfig poolConfig)
Constructs a new
JedisConnectionFactory instance using the given JedisPoolConfig applied to
JedisSentinelPool. |
| Modifier and Type | Method and Description |
|---|---|
void |
afterPropertiesSet() |
protected redis.clients.util.Pool<redis.clients.jedis.Jedis> |
createRedisPool()
Creates
JedisPool. |
protected redis.clients.util.Pool<redis.clients.jedis.Jedis> |
createRedisSentinelPool(RedisSentinelConfiguration config)
Creates
JedisSentinelPool. |
void |
destroy() |
protected redis.clients.jedis.Jedis |
fetchJedisConnector()
Returns a Jedis instance to be used as a Redis connection.
|
JedisConnection |
getConnection()
Provides a suitable connection for interacting with Redis.
|
boolean |
getConvertPipelineAndTxResults()
Specifies if pipelined results should be converted to the expected data type.
|
int |
getDatabase()
Returns the index of the database.
|
String |
getHostName()
Returns the Redis hostName.
|
String |
getPassword()
Returns the password used for authenticating with the Redis server.
|
redis.clients.jedis.JedisPoolConfig |
getPoolConfig()
Returns the poolConfig.
|
int |
getPort()
Returns the port used to connect to the Redis instance.
|
RedisSentinelConnection |
getSentinelConnection() |
redis.clients.jedis.JedisShardInfo |
getShardInfo()
Returns the shardInfo.
|
int |
getTimeout()
Returns the timeout.
|
boolean |
getUsePool()
Indicates the use of a connection pool.
|
boolean |
isRedisSentinelAware() |
protected JedisConnection |
postProcessConnection(JedisConnection connection)
Post process a newly retrieved connection.
|
void |
setConvertPipelineAndTxResults(boolean convertPipelineAndTxResults)
Specifies if pipelined results should be converted to the expected data type.
|
void |
setDatabase(int index)
Sets the index of the database used by this connection factory.
|
void |
setHostName(String hostName)
Sets the Redis hostName.
|
void |
setPassword(String password)
Sets the password used for authenticating with the Redis server.
|
void |
setPoolConfig(redis.clients.jedis.JedisPoolConfig poolConfig)
Sets the pool configuration for this factory.
|
void |
setPort(int port)
Sets the port used to connect to the Redis instance.
|
void |
setShardInfo(redis.clients.jedis.JedisShardInfo shardInfo)
Sets the shard info for this factory.
|
void |
setTimeout(int timeout) |
void |
setUsePool(boolean usePool)
Turns on or off the use of connection pooling.
|
DataAccessException |
translateExceptionIfPossible(RuntimeException ex) |
public JedisConnectionFactory()
JedisConnectionFactory instance with default settings (default connection pooling, no
shard information).public JedisConnectionFactory(redis.clients.jedis.JedisShardInfo shardInfo)
JedisConnectionFactory instance. Will override the other connection parameters passed
to the factory.shardInfo - shard informationpublic JedisConnectionFactory(redis.clients.jedis.JedisPoolConfig poolConfig)
JedisConnectionFactory instance using the given pool configuration.poolConfig - pool configurationpublic JedisConnectionFactory(RedisSentinelConfiguration sentinelConfig)
JedisConnectionFactory instance using the given JedisPoolConfig applied to
JedisSentinelPool.sentinelConfig - public JedisConnectionFactory(RedisSentinelConfiguration sentinelConfig, redis.clients.jedis.JedisPoolConfig poolConfig)
JedisConnectionFactory instance using the given JedisPoolConfig applied to
JedisSentinelPool.sentinelConfig - poolConfig - pool configuration. Defaulted to new instance if null.protected redis.clients.jedis.Jedis fetchJedisConnector()
RedisConnection.protected JedisConnection postProcessConnection(JedisConnection connection)
connection - public void afterPropertiesSet()
afterPropertiesSet in interface InitializingBeanprotected redis.clients.util.Pool<redis.clients.jedis.Jedis> createRedisSentinelPool(RedisSentinelConfiguration config)
JedisSentinelPool.config - protected redis.clients.util.Pool<redis.clients.jedis.Jedis> createRedisPool()
JedisPool.public void destroy()
destroy in interface DisposableBeanpublic JedisConnection getConnection()
RedisConnectionFactorygetConnection in interface RedisConnectionFactorypublic DataAccessException translateExceptionIfPossible(RuntimeException ex)
translateExceptionIfPossible in interface PersistenceExceptionTranslatorpublic String getHostName()
public void setHostName(String hostName)
hostName - The hostName to set.public String getPassword()
public void setPassword(String password)
password - the password to setpublic int getPort()
public void setPort(int port)
port - Redis portpublic redis.clients.jedis.JedisShardInfo getShardInfo()
public void setShardInfo(redis.clients.jedis.JedisShardInfo shardInfo)
shardInfo - The shardInfo to set.public int getTimeout()
public void setTimeout(int timeout)
timeout - The timeout to set.public boolean getUsePool()
public void setUsePool(boolean usePool)
usePool - The usePool to set.public redis.clients.jedis.JedisPoolConfig getPoolConfig()
public void setPoolConfig(redis.clients.jedis.JedisPoolConfig poolConfig)
poolConfig - The poolConfig to set.public int getDatabase()
public void setDatabase(int index)
index - database indexpublic boolean getConvertPipelineAndTxResults()
JedisConnection.closePipeline() and JedisConnection.exec() will be of the type returned by the
Jedis drivergetConvertPipelineAndTxResults in interface RedisConnectionFactorypublic void setConvertPipelineAndTxResults(boolean convertPipelineAndTxResults)
JedisConnection.closePipeline() and JedisConnection.exec() will be of the type returned by the
Jedis driverconvertPipelineAndTxResults - Whether or not to convert pipeline and tx resultspublic boolean isRedisSentinelAware()
RedisSentinelConfiguration is present.public RedisSentinelConnection getSentinelConnection()
getSentinelConnection in interface RedisConnectionFactory