public class AsyncRedisConnection extends AbstractAsyncRedisClient
Modifier and Type | Field and Description |
---|---|
static ExecutorService |
bootstrapExecutor
Executor used to initialize the pipeline when there is no NIO request listener.
|
static ClassDescriptorStorageFactory |
DEFAULT_CLASS_DESCRIPTOR_STORAGE_FACTORY
Default Per Connection Class Descriptor Storage used by OPTI_JAVA_HANDLER.
|
static DataHandler |
DEFAULT_HANDLER
The Default Data Handler if none is configured.
|
static int |
DEFAULT_MAX_PIPELINE_SIZE
Default value of max pipeline size to restrict the number of commands in pipeline after which the request processing is suspended till the pipeline size reduces.
|
static DataHandler |
JAVA_HANDLER
This
DataHandler is an instance of JavaHandler with normal Object serialization. |
static DataHandler |
JAVA_HANDLER_NO_COMPRESS
Identical to JAVA_HANDLER but without compression.
|
static DataHandler |
KEY_HANDLER
This
DataHandler is an instance of StringHandler . |
static int |
MAX_SHUTDOWN_WAIT_MILLIS |
static DataHandler |
OPTI_JAVA_HANDLER
This
DataHandler is an instance of JavaHandler . |
static DataHandler |
OPTI_JAVA_HANDLER_NO_COMPRESS
Identical to OPTI_JAVA_HANDLER but without compression.
|
static Thread |
shutDownHook |
protected Executor |
taskExecutor
Task executor for invoking completionHandlers for Async commands.
|
Constructor and Description |
---|
AsyncRedisConnection(AsyncSocketTransport pcon,
int pdbIndex,
Executor ptaskExecutor)
Constructor to create a SHARED AsyncRedisConnection.
|
AsyncRedisConnection(AsyncSocketTransport pcon,
int pdbIndex,
Executor ptaskExecutor,
ConnectionType pconnectionType)
Constructor to create an AsyncRedisConnection of the given connection type.
|
Modifier and Type | Method and Description |
---|---|
void |
closeStaleConnection()
Closes the connection if it has been idle beyond the configured idle timeout or the Redis Server timeout.
|
AsyncSocketTransport |
getConnection()
Returns the Async Socket Transport used
|
DataHandler |
getDataHandler()
The default
DataHandler for commands |
int |
getDbIndex()
Returns the DB Index of the connection
|
int |
getMaxPipelineSize()
Max Pipeline Size
|
static void |
setBootstrapExecutorPoolSize(int poolSize)
Method to change the size of the bootstrapExecutor
|
void |
setDataHandler(DataHandler pdataHandler)
Sets the default
DataHandler for commands |
void |
setMaxPipelineSize(int pmaxPipelineSize)
Sets the max number of commands pending for response in the Redis Server.
|
void |
shutdown(long delayMillis)
Shutdown the connection.
|
Future<RedisCommandInfo> |
submitCommand(RedisCommandInfo command,
AsyncHandler<RedisCommandInfo> completionHandler,
boolean requireFutureResult,
boolean isSyncCallback)
Submit a Redis Command.
|
Future<RedisCommandInfo[]> |
submitCommands(RedisCommandInfo[] commands,
AsyncHandler<RedisCommandInfo[]> completionHandler,
boolean requireFutureResult,
boolean isSyncCallback)
Submit multiple Redis Commands.
|
sendCommand, sendCommand, sendCommand, sendCommand, submitCommand, submitCommand, submitCommand, submitCommand, submitCommand, submitCommand, submitCommand, submitCommand, submitCommand, submitCommand, submitCommands, submitCommands
public static final DataHandler KEY_HANDLER
DataHandler
is an instance of StringHandler
. It is also used to serialize keys and other non-value parameters to the Redis Commands.public static final ClassDescriptorStorageFactory DEFAULT_CLASS_DESCRIPTOR_STORAGE_FACTORY
public static final DataHandler OPTI_JAVA_HANDLER
DataHandler
is an instance of JavaHandler
. It is configured to optimize object storage by storing the class descriptors for the classes separately.public static final DataHandler JAVA_HANDLER
DataHandler
is an instance of JavaHandler
with normal Object serialization.public static final DataHandler OPTI_JAVA_HANDLER_NO_COMPRESS
public static final DataHandler JAVA_HANDLER_NO_COMPRESS
public static final DataHandler DEFAULT_HANDLER
public static final int DEFAULT_MAX_PIPELINE_SIZE
public static final ExecutorService bootstrapExecutor
public static final Thread shutDownHook
public static volatile int MAX_SHUTDOWN_WAIT_MILLIS
protected Executor taskExecutor
public AsyncRedisConnection(AsyncSocketTransport pcon, int pdbIndex, Executor ptaskExecutor, ConnectionType pconnectionType)
AsyncRedisFactory
than this constructor.pcon
- Async Socket Transport implementationpdbIndex
- Redis DB indexptaskExecutor
- Task Executor to use for Asyc APIs. Can be null if you do not use Async APIs with completion handlerpconnectionType
- ConnectionType indicating type of connection. A normal SHARED connection type is for Shared usage and the WATCH command is not allowed.
If the ConnectionType is BORROWED WATCH is allowed but not blocking commands like BLPOP. If the ConnectionType is STANDALONE all commands except SUBSCRIBE are allowed.public AsyncRedisConnection(AsyncSocketTransport pcon, int pdbIndex, Executor ptaskExecutor)
AsyncRedisFactory
than this constructor.pcon
- Async Socket Transport implementationpdbIndex
- Redis DB indexptaskExecutor
- Task Executor to use for Asyc APIs. Can be null if you do not use Async APIs with completion handlerpublic void closeStaleConnection()
public void shutdown(long delayMillis)
delayMillis
- Max delay till which to support commandspublic Future<RedisCommandInfo[]> submitCommands(RedisCommandInfo[] commands, AsyncHandler<RedisCommandInfo[]> completionHandler, boolean requireFutureResult, boolean isSyncCallback)
AsyncRedisClient
submitCommands
in interface AsyncRedisClient
submitCommands
in class AbstractAsyncRedisClient
commands
- commands to run along with their parameterscompletionHandler
- Handler to call upon command completion. Can be nullrequireFutureResult
- Whether a Future return value is requiredisSyncCallback
- If true the callback is made directly by the Socket Channel Thread and not the configured executor. Pass true only if the handler logic is extremely light like moving the command to another Q.public Future<RedisCommandInfo> submitCommand(RedisCommandInfo command, AsyncHandler<RedisCommandInfo> completionHandler, boolean requireFutureResult, boolean isSyncCallback)
AsyncRedisClient
submitCommand
in interface AsyncRedisClient
submitCommand
in class AbstractAsyncRedisClient
command
- command to run along with its parameterscompletionHandler
- Handler to call upon command completion. Can be nullrequireFutureResult
- Whether a Future return value is requiredisSyncCallback
- If true the callback is made directly by the Socket Channel Thread and not the configured executor. Pass true only if the handler logic is extremely light like moving the command to another Q.public AsyncSocketTransport getConnection()
public int getDbIndex()
public DataHandler getDataHandler()
DataHandler
for commandspublic void setDataHandler(DataHandler pdataHandler)
DataHandler
for commandspdataHandler
- Data Handler to setpublic int getMaxPipelineSize()
public void setMaxPipelineSize(int pmaxPipelineSize)
pmaxPipelineSize
- max number of commands allowed in Redis Server pipelinepublic static void setBootstrapExecutorPoolSize(int poolSize)
poolSize
- New Pool sizeCopyright © 2013- Suresh Mahalingam. All Rights Reserved.