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(RedisClusterConfiguration clusterConfig)
Constructs a new
JedisConnectionFactory instance using the given RedisClusterConfiguration applied
to create a JedisCluster . |
JedisConnectionFactory(RedisClusterConfiguration clusterConfig,
redis.clients.jedis.JedisPoolConfig poolConfig)
Constructs a new
JedisConnectionFactory instance using the given RedisClusterConfiguration applied
to create a JedisCluster . |
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.jedis.JedisCluster |
createCluster(RedisClusterConfiguration clusterConfig,
org.apache.commons.pool2.impl.GenericObjectPoolConfig poolConfig)
|
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.
|
RedisClusterConnection |
getClusterConnection()
Provides a suitable connection for interacting with Redis Cluster.
|
RedisConnection |
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.
|
ReactiveRedisClusterConnection |
getReactiveClusterConnection() |
ReactiveRedisConnection |
getReactiveConnection() |
RedisSentinelConnection |
getSentinelConnection()
Provides a suitable connection for interacting with Redis Sentinel.
|
redis.clients.jedis.JedisShardInfo |
getShardInfo()
Returns the shardInfo.
|
int |
getTimeout()
Returns the timeout.
|
boolean |
getUsePool()
Indicates the use of a connection pool.
|
boolean |
isRedisSentinelAware() |
boolean |
isUseSsl()
Returns whether to use SSL.
|
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.
|
void |
setUseSsl(boolean useSsl)
Sets whether to use SSL.
|
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.public JedisConnectionFactory(RedisClusterConfiguration clusterConfig)
JedisConnectionFactory
instance using the given RedisClusterConfiguration
applied
to create a JedisCluster
.clusterConfig
- public JedisConnectionFactory(RedisClusterConfiguration clusterConfig, redis.clients.jedis.JedisPoolConfig poolConfig)
JedisConnectionFactory
instance using the given RedisClusterConfiguration
applied
to create a JedisCluster
.clusterConfig
- protected redis.clients.jedis.Jedis fetchJedisConnector()
RedisConnection
.protected JedisConnection postProcessConnection(JedisConnection connection)
connection
- public void afterPropertiesSet()
afterPropertiesSet
in interface InitializingBean
protected redis.clients.util.Pool<redis.clients.jedis.Jedis> createRedisSentinelPool(RedisSentinelConfiguration config)
JedisSentinelPool
.config
- protected redis.clients.util.Pool<redis.clients.jedis.Jedis> createRedisPool()
JedisPool
.protected redis.clients.jedis.JedisCluster createCluster(RedisClusterConfiguration clusterConfig, org.apache.commons.pool2.impl.GenericObjectPoolConfig poolConfig)
clusterConfig
- must not be null.poolConfig
- can be null.public void destroy()
destroy
in interface DisposableBean
public RedisConnection getConnection()
RedisConnectionFactory
getConnection
in interface RedisConnectionFactory
public RedisClusterConnection getClusterConnection()
RedisConnectionFactory
getClusterConnection
in interface RedisConnectionFactory
public ReactiveRedisConnection getReactiveConnection()
getReactiveConnection
in interface RedisConnectionFactory
public ReactiveRedisClusterConnection getReactiveClusterConnection()
getReactiveClusterConnection
in interface RedisConnectionFactory
public DataAccessException translateExceptionIfPossible(RuntimeException ex)
translateExceptionIfPossible
in interface PersistenceExceptionTranslator
public String getHostName()
public void setHostName(String hostName)
hostName
- The hostName to set.public void setUseSsl(boolean useSsl)
useSsl
- true to use SSL.public boolean isUseSsl()
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 RedisConnectionFactory
public 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()
RedisConnectionFactory
getSentinelConnection
in interface RedisConnectionFactory
Copyright © 2011-2016–2016 Pivotal Software, Inc.. All rights reserved.