public class AsyncRedisFactory extends Object
AsyncRedisConnection
,
AsyncObjectPool
RedisSubscription
. In a server environment it should
be configured as a Singleton or as a Spring Bean. It returns the Same Service Object on Subsequent calls for the
same server or comma separated list of servers. Currently the AsyncRedisConnection there is no way to free
AsyncRedisConnection Objects that are no longer needed. But the connections close after the configured idle timeout.Constructor and Description |
---|
AsyncRedisFactory(AsyncSocketTransportFactory ptransportFactory,
Executor pexecutor)
Creates an AsyncRedisFactory Object with a default pool size of 10 and Shutdown delay of 10 seconds.
|
AsyncRedisFactory(AsyncSocketTransportFactory ptransportFactory,
Executor pexecutor,
int ppoolSize,
int pshutdownDelay)
Creates an AsyncRedisFactory Object.
|
AsyncRedisFactory(Executor pexecutor)
Creates an AsyncRedisFactory Object with the default Transport Factory, a default pool size of 10 and Shutdown delay of 10 seconds.
|
Modifier and Type | Method and Description |
---|---|
static String |
getAuth(ServerInfo serverInfo)
Gets the Configured Authentication for the given serverInfo.
|
static String |
getAuth(String connectionString)
Gets the Configured Authentication for the Redis Server with the given connectionString.
|
AsyncRedisClient |
getClient(String connectionString)
Returns an AsyncRedisClient from a connection string containing one or more redis servers.
|
AsyncRedisClient |
getClient(String connectionString,
Executor pexecutor)
Returns an AsyncRedisClient from a connection string containing one or more redis servers.
|
AsyncRedisConnection |
getConnection(RedisServerInfo redisServerInfo)
Returns an AsycRedisConnection.
|
AsyncRedisConnection |
getConnection(RedisServerInfo redisServerInfo,
Executor pexecutor)
Returns an AsycRedisConnection.
|
AsyncObjectPool<AsyncRedisConnection> |
getConnectionPool(RedisServerInfo redisServerInfo)
Returns a connection pool for use in Redis Transactions with WATCH-MULTI-EXEC commands.
|
AsyncObjectPool<AsyncRedisConnection> |
getConnectionPool(RedisServerInfo redisServerInfo,
Executor pexecutor)
Returns a connection pool for use in Redis Transactions with WATCH-MULTI-EXEC commands.
|
AsyncObjectPool<AsyncRedisConnection> |
getConnectionPool(String connectionString)
Returns an AsyncObjectPool holding AsyncRedisConnection objects for WATCH-MULTI-EXEC redis transactions.
|
AsyncObjectPool<AsyncRedisConnection> |
getConnectionPool(String connectionString,
Executor pexecutor)
Returns an AsyncObjectPool holding AsyncRedisConnection objects for WATCH-MULTI-EXEC redis transactions.
|
DataHandler |
getDataHandler()
Gets the Data Handler used by the factory.
|
Executor |
getExecutor()
Gets the configured Executor for this factory or null if none is configured.
|
int |
getPoolSize()
Gets the pool size used when creating a connection pool
|
RedisSubscription |
getSubscription(RedisServerInfo redisServerInfo)
Returns a RedisSubscription object for subscribing to messages and message patterns on the given Redis Server.
|
RedisSubscription |
getSubscription(RedisServerInfo redisServerInfo,
Executor pexecutor)
Returns a RedisSubscription object for subscribing to messages and message patterns on the given Redis Server.
|
RedisSubscription |
getSubscription(String connectionString)
Returns a RedisSubscription object for subscribing to messages and message patterns on the given Redis Server.
|
RedisSubscription |
getSubscription(String connectionString,
Executor pexecutor)
Returns a RedisSubscription object for subscribing to messages and message patterns on the given Redis Server.
|
AsyncSocketTransportFactory |
getSubscriptionTransportFactory()
Gets the Transport Factory used for RedisSuubscription service or null if none is set.
|
static RedisTimer |
getTimer()
Gets the static instance of RedisTimer in use for periodic tasks re-connects, Leak Checks etc.
|
AsyncSocketTransportFactory |
getTransportFactory()
Gets the default Transport Factory which is also used for AsyncRedisConnections.
|
AsyncSocketTransportFactory |
pgetPoolTransportFactory()
Gets the Transport Factory used when creating a connection pool.
|
static void |
setAuth(ServerInfo serverInfo,
String auth)
Sets Password for authentication if the redis server is configured with a password via requirepass
directive in redis.conf.
|
static void |
setAuth(String connectionString,
String auth)
Sets Password for authentication if the redis server is configured with a password via requirepass
directive in redis.conf.
|
void |
setDataHandler(DataHandler pdataHandler)
Sets the Data Handler used by the factory
|
void |
setPoolSize(int ppoolSize)
Sets the pool size to use when creating a connection pool
|
void |
setPoolTransportFactory(AsyncSocketTransportFactory ppoolTransportFactory)
Sets the Transport Factory to use when creating a connection pool.
|
void |
setSubscriptionTransportFactory(AsyncSocketTransportFactory psubscriptionTransportFactory)
Sets the Transport Factory to Use for RedisSuubscription service.
|
static void |
setTimer(RedisTimer ptimer)
Sets the RedisTimer to use.
|
public AsyncRedisFactory(AsyncSocketTransportFactory ptransportFactory, Executor pexecutor, int ppoolSize, int pshutdownDelay)
ptransportFactory
- Connection Factory to use to create AsyncSocketTransport
pexecutor
- Common Executor to use for aredis servicesppoolSize
- Pool Size when creating a connection poolpshutdownDelay
- Shutdown delay in seconds when shutting down. This is currently not used.public AsyncRedisFactory(AsyncSocketTransportFactory ptransportFactory, Executor pexecutor)
ptransportFactory
- Connection Factory to use to create AsyncSocketTransport
pexecutor
- Common Executor to use for aredis servicespublic AsyncRedisFactory(Executor pexecutor)
pexecutor
- Common Executor to use for aredis servicespublic AsyncRedisConnection getConnection(RedisServerInfo redisServerInfo, Executor pexecutor)
redisServerInfo
- Redis Server Info containing host, port and DB Indexpexecutor
- Specific Executor to use for the connection returned or null to use the Factory's Executor.public AsyncRedisConnection getConnection(RedisServerInfo redisServerInfo)
redisServerInfo
- Redis Server Info containing host, port and DB Indexpublic AsyncObjectPool<AsyncRedisConnection> getConnectionPool(RedisServerInfo redisServerInfo, Executor pexecutor)
redisServerInfo
- Redis Server Info containing host, port and DB Indexpexecutor
- Specific Executor to use for the connection pool returned or null to use the Factory's Executor.public AsyncObjectPool<AsyncRedisConnection> getConnectionPool(RedisServerInfo redisServerInfo)
redisServerInfo
- Redis Server Info containing host, port and DB Indexpublic AsyncRedisClient getClient(String connectionString, Executor pexecutor)
connectionString
- Connection Stringpexecutor
- Specific Executor to use for the client returned or null to use the Factory's Executor.public AsyncRedisClient getClient(String connectionString)
connectionString
- Connection Stringpublic AsyncObjectPool<AsyncRedisConnection> getConnectionPool(String connectionString, Executor pexecutor)
connectionString
- Connection String specifying a single redis serverpexecutor
- Specific Executor to use for the pool returned or null to use the Factory's Executor.public AsyncObjectPool<AsyncRedisConnection> getConnectionPool(String connectionString)
connectionString
- Connection String specifying a single redis serverpublic RedisSubscription getSubscription(RedisServerInfo redisServerInfo, Executor pexecutor)
redisServerInfo
- Redis Server Info containing host, port and DB Indexpexecutor
- Specific Executor to use for the RedisSubscription returned or null to use the Factory's Executor.public RedisSubscription getSubscription(RedisServerInfo redisServerInfo)
redisServerInfo
- Redis Server Info containing host, port and DB Indexpublic RedisSubscription getSubscription(String connectionString, Executor pexecutor)
connectionString
- Connection String specifying a single redis serverpexecutor
- Specific Executor to use for the RedisSubscription returned or null to use the Factory's Executor.public RedisSubscription getSubscription(String connectionString)
connectionString
- Connection String specifying a single redis serverpublic static RedisTimer getTimer()
public static void setTimer(RedisTimer ptimer)
ptimer
- Timer to setpublic DataHandler getDataHandler()
public void setDataHandler(DataHandler pdataHandler)
pdataHandler
- The Default Data Handler to use when creating a redis service or null if none setpublic int getPoolSize()
public void setPoolSize(int ppoolSize)
ppoolSize
- pool sizepublic AsyncSocketTransportFactory pgetPoolTransportFactory()
public void setPoolTransportFactory(AsyncSocketTransportFactory ppoolTransportFactory)
ppoolTransportFactory
- Transport factory for connection poolspublic AsyncSocketTransportFactory getSubscriptionTransportFactory()
public void setSubscriptionTransportFactory(AsyncSocketTransportFactory psubscriptionTransportFactory)
psubscriptionTransportFactory
- Transport Factory for RedisSubscriptionpublic AsyncSocketTransportFactory getTransportFactory()
public Executor getExecutor()
public static String getAuth(ServerInfo serverInfo)
serverInfo
- Redis Server Info giving host and portpublic static void setAuth(ServerInfo serverInfo, String auth)
serverInfo
- Redis Server Info giving host and port. It can be got by getConnection call on AsyncRedisConnection
or RedisSubscription
or by constructing a RedisServerInfo
auth
- Password to set or null if there is no password which is the defaultpublic static String getAuth(String connectionString)
getAuth(ServerInfo)
after creating a RedisServerInfo Object.connectionString
- Connection String for the Redis Serverpublic static void setAuth(String connectionString, String auth)
setAuth(ServerInfo, String)
after creating a RedisServerInfo Object.connectionString
- Connection String for the Redis Serverauth
- Password to set or null if there is no password which is the defaultCopyright © 2013- Suresh Mahalingam. All Rights Reserved.