org.springframework.data.redis.connection.jredis
Class JredisConnectionFactory

java.lang.Object
  extended by org.springframework.data.redis.connection.jredis.JredisConnectionFactory
All Implemented Interfaces:
DisposableBean, InitializingBean, PersistenceExceptionTranslator, RedisConnectionFactory

public class JredisConnectionFactory
extends Object
implements InitializingBean, DisposableBean, RedisConnectionFactory

Connection factory using creating JRedis based connections.


Constructor Summary
JredisConnectionFactory()
          Constructs a new JredisConnectionFactory instance.
JredisConnectionFactory(org.jredis.connector.ConnectionSpec connectionSpec)
          Constructs a new JredisConnectionFactory instance.
JredisConnectionFactory(Pool<org.jredis.JRedis> pool)
           
 
Method Summary
 void afterPropertiesSet()
           
 void destroy()
           
 RedisConnection getConnection()
          Provides a suitable connection for interacting with Redis.
 boolean getConvertPipelineAndTxResults()
          JredisConnection does not support pipeline or transactions
 int getDatabase()
          Returns the index of the database.
 String getHostName()
          Returns the Redis host name of this factory.
 String getPassword()
          Returns the password used for authenticating with the Redis server.
 int getPort()
          Returns the Redis port.
protected  RedisConnection postProcessConnection(JredisConnection connection)
          Post process a newly retrieved connection.
 void setDatabase(int index)
          Sets the index of the database used by this connection factory.
 void setHostName(String hostName)
          Sets the Redis host name for this factory.
 void setPassword(String password)
          Sets the password used for authenticating with the Redis server.
 void setPort(int port)
          Sets the Redis port.
 DataAccessException translateExceptionIfPossible(RuntimeException ex)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JredisConnectionFactory

public JredisConnectionFactory()
Constructs a new JredisConnectionFactory instance.


JredisConnectionFactory

public JredisConnectionFactory(org.jredis.connector.ConnectionSpec connectionSpec)
Constructs a new JredisConnectionFactory instance. Will override the other connection parameters passed to the factory.

Parameters:
connectionSpec - already configured connection.

JredisConnectionFactory

public JredisConnectionFactory(Pool<org.jredis.JRedis> pool)
Method Detail

afterPropertiesSet

public void afterPropertiesSet()
Specified by:
afterPropertiesSet in interface InitializingBean

destroy

public void destroy()
             throws Exception
Specified by:
destroy in interface DisposableBean
Throws:
Exception

getConnection

public RedisConnection getConnection()
Description copied from interface: RedisConnectionFactory
Provides a suitable connection for interacting with Redis.

Specified by:
getConnection in interface RedisConnectionFactory
Returns:
connection for interacting with Redis.

postProcessConnection

protected RedisConnection postProcessConnection(JredisConnection connection)
Post process a newly retrieved connection. Useful for decorating or executing initialization commands on a new connection. This implementation simply returns the connection.

Parameters:
connection -
Returns:
processed connection

translateExceptionIfPossible

public DataAccessException translateExceptionIfPossible(RuntimeException ex)
Specified by:
translateExceptionIfPossible in interface PersistenceExceptionTranslator

getHostName

public String getHostName()
Returns the Redis host name of this factory.

Returns:
Returns the hostName

setHostName

public void setHostName(String hostName)
Sets the Redis host name for this factory.

Parameters:
hostName - The hostName to set.

getPort

public int getPort()
Returns the Redis port.

Returns:
Returns the port

setPort

public void setPort(int port)
Sets the Redis port.

Parameters:
port - The port to set.

getPassword

public String getPassword()
Returns the password used for authenticating with the Redis server.

Returns:
password for authentication

setPassword

public void setPassword(String password)
Sets the password used for authenticating with the Redis server.

Parameters:
password - the password to set

getDatabase

public int getDatabase()
Returns the index of the database.

Returns:
Returns the database index

setDatabase

public void setDatabase(int index)
Sets the index of the database used by this connection factory. Can be between 0 (default) and 15.

Parameters:
index - database index

getConvertPipelineAndTxResults

public boolean getConvertPipelineAndTxResults()
JredisConnection does not support pipeline or transactions

Specified by:
getConvertPipelineAndTxResults in interface RedisConnectionFactory
Returns:
Whether or not to convert pipeline and tx results