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.
 
Method Summary
 void afterPropertiesSet()
           
 void destroy()
           
 RedisConnection getConnection()
          Provides a suitable connection for interacting with Redis.
 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 getPoolSize()
          Returns the pool size of this factory.
 int getPort()
          Returns the Redis port.
 boolean getUsePool()
          Indicates the use of a connection pool.
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 setPoolSize(int poolSize)
          Sets the connection pool size of the underlying factory.
 void setPort(int port)
          Sets the Redis port.
 void setUsePool(boolean usePool)
          Turns on or off the use of connection pooling.
 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.
Method Detail

afterPropertiesSet

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

destroy

public void destroy()
Specified by:
destroy in interface DisposableBean

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

getUsePool

public boolean getUsePool()
Indicates the use of a connection pool.

Returns:
Returns the use of connection pooling.

setUsePool

public void setUsePool(boolean usePool)
Turns on or off the use of connection pooling.

Parameters:
usePool - The usePool to set.

getPoolSize

public int getPoolSize()
Returns the pool size of this factory.

Returns:
Returns the poolSize

setPoolSize

public void setPoolSize(int poolSize)
Sets the connection pool size of the underlying factory.

Parameters:
poolSize - The poolSize 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