org.springframework.data.redis.connection.lettuce
Class DefaultLettucePool

java.lang.Object
  

extended by org.springframework.data.redis.connection.lettuce.DefaultLettucePool
All Implemented Interfaces:
InitializingBean, LettucePool, Pool<com.lambdaworks.redis.RedisAsyncConnection<byte[],byte[]>>

public class DefaultLettucePool
extends Object
implements LettucePool, InitializingBean

Default implementation of LettucePool.


Constructor Summary
DefaultLettucePool()
          Constructs a new DefaultLettucePool instance with default settings.
DefaultLettucePool(String hostName, int port)
          Uses the Config and RedisClient defaults for configuring the connection pool
DefaultLettucePool(String hostName, int port, org.apache.commons.pool2.impl.GenericObjectPoolConfig poolConfig)
          Uses the RedisClient defaults for configuring the connection pool
 
Method Summary
 void afterPropertiesSet()
           
 void destroy()
          Destroys the pool
 com.lambdaworks.redis.RedisClient getClient()
           
 int getDatabase()
          Returns the index of the database.
 String getHostName()
          Returns the current host.
 String getPassword()
          Returns the password used for authenticating with the Redis server.
 org.apache.commons.pool2.impl.GenericObjectPoolConfig getPoolConfig()
           
 int getPort()
          Returns the current port.
 com.lambdaworks.redis.RedisAsyncConnection<byte[],byte[]> getResource()
           
 long getTimeout()
          Returns the connection timeout (in milliseconds).
 void returnBrokenResource(com.lambdaworks.redis.RedisAsyncConnection<byte[],byte[]> resource)
           
 void returnResource(com.lambdaworks.redis.RedisAsyncConnection<byte[],byte[]> resource)
           
 void setDatabase(int index)
          Sets the index of the database used by this connection pool.
 void setHostName(String host)
          Sets the host.
 void setPassword(String password)
          Sets the password used for authenticating with the Redis server.
 void setPoolConfig(org.apache.commons.pool2.impl.GenericObjectPoolConfig poolConfig)
           
 void setPort(int port)
          Sets the port.
 void setTimeout(long timeout)
          Sets the connection timeout (in milliseconds).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultLettucePool

public DefaultLettucePool()
Constructs a new DefaultLettucePool instance with default settings.


DefaultLettucePool

public DefaultLettucePool(String hostName,
                          int port)
Uses the Config and RedisClient defaults for configuring the connection pool

Parameters:
hostName - The Redis host
port - The Redis port

DefaultLettucePool

public DefaultLettucePool(String hostName,
                          int port,
                          org.apache.commons.pool2.impl.GenericObjectPoolConfig poolConfig)
Uses the RedisClient defaults for configuring the connection pool

Parameters:
hostName - The Redis host
port - The Redis port
poolConfig - The pool GenericObjectPoolConfig
Method Detail

afterPropertiesSet

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

getResource

public com.lambdaworks.redis.RedisAsyncConnection<byte[],byte[]> getResource()
Specified by:
getResource in interface Pool<com.lambdaworks.redis.RedisAsyncConnection<byte[],byte[]>>
Returns:
A resource, if available

returnBrokenResource

public void returnBrokenResource(com.lambdaworks.redis.RedisAsyncConnection<byte[],byte[]> resource)
Specified by:
returnBrokenResource in interface Pool<com.lambdaworks.redis.RedisAsyncConnection<byte[],byte[]>>
Parameters:
resource - A broken resource that should be invalidated

returnResource

public void returnResource(com.lambdaworks.redis.RedisAsyncConnection<byte[],byte[]> resource)
Specified by:
returnResource in interface Pool<com.lambdaworks.redis.RedisAsyncConnection<byte[],byte[]>>
Parameters:
resource - A resource to return to the pool

destroy

public void destroy()
Description copied from interface: Pool
Destroys the pool

Specified by:
destroy in interface Pool<com.lambdaworks.redis.RedisAsyncConnection<byte[],byte[]>>

getClient

public com.lambdaworks.redis.RedisClient getClient()
Specified by:
getClient in interface LettucePool
Returns:
The RedisClient used to create pooled connections

getPoolConfig

public org.apache.commons.pool2.impl.GenericObjectPoolConfig getPoolConfig()
Returns:
The pool configuration

setPoolConfig

public void setPoolConfig(org.apache.commons.pool2.impl.GenericObjectPoolConfig poolConfig)
Parameters:
poolConfig - The pool configuration to use

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 pool. Default is 0.

Parameters:
index - database index

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

getHostName

public String getHostName()
Returns the current host.

Returns:
the host

setHostName

public void setHostName(String host)
Sets the host.

Parameters:
host - the host to set

getPort

public int getPort()
Returns the current port.

Returns:
the port

setPort

public void setPort(int port)
Sets the port.

Parameters:
port - the port to set

getTimeout

public long getTimeout()
Returns the connection timeout (in milliseconds).

Returns:
connection timeout

setTimeout

public void setTimeout(long timeout)
Sets the connection timeout (in milliseconds).

Parameters:
timeout - connection timeout