K
- Key type.V
- Value type.@ChannelHandler.Sharable public class StatefulRedisConnectionImpl<K,V> extends RedisChannelHandler<K,V> implements StatefulRedisConnection<K,V>
StatefulRedisConnectionImpl
A ConnectionWatchdog
monitors each connection and reconnects automatically until RedisChannelHandler.close()
is called. All
pending commands will be (re)sent after successful reconnection.ChannelHandler.Sharable
Modifier and Type | Field and Description |
---|---|
protected RedisAsyncCommandsImpl<K,V> |
async |
protected RedisCodec<K,V> |
codec |
protected MultiOutput<K,V> |
multi |
protected RedisReactiveCommandsImpl<K,V> |
reactive |
protected RedisCommands<K,V> |
sync |
timeout, unit
Constructor and Description |
---|
StatefulRedisConnectionImpl(RedisChannelWriter<K,V> writer,
RedisCodec<K,V> codec,
long timeout,
TimeUnit unit)
Initialize a new connection.
|
Modifier and Type | Method and Description |
---|---|
void |
activated()
Notification when the connection becomes active (connected).
|
RedisAsyncCommands<K,V> |
async()
Returns the
RedisAsyncCommands API for the current connection. |
<T,C extends RedisCommand<K,V,T>> |
dispatch(C cmd)
Dispatch a command.
|
protected RedisAsyncCommandsImpl<K,V> |
getAsyncCommands() |
protected RedisReactiveCommandsImpl<K,V> |
getReactiveCommands() |
boolean |
isMulti() |
protected RedisAsyncCommandsImpl<K,V> |
newRedisAsyncCommandsImpl()
Create a new instance of
RedisAsyncCommandsImpl . |
protected RedisReactiveCommandsImpl<K,V> |
newRedisReactiveCommandsImpl()
Create a new instance of
RedisReactiveCommandsImpl . |
RedisReactiveCommands<K,V> |
reactive()
Returns the
RedisReactiveCommands API for the current connection. |
RedisCommands<K,V> |
sync()
Returns the
RedisCommands API for the current connection. |
addListener, channelRead, channelRead, channelRegistered, close, deactivated, flushCommands, getChannelWriter, getOptions, getTimeout, getTimeoutUnit, isClosed, isOpen, registerCloseables, reset, setAutoFlushCommands, setOptions, setTimeout, syncHandler
channelActive, channelInactive, channelReadComplete, channelUnregistered, channelWritabilityChanged, exceptionCaught, userEventTriggered
handlerAdded, handlerRemoved, isSharable
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
close, flushCommands, getOptions, getTimeout, getTimeoutUnit, isOpen, reset, setAutoFlushCommands, setTimeout
handlerAdded, handlerRemoved
protected RedisCodec<K,V> codec
protected RedisCommands<K,V> sync
protected RedisAsyncCommandsImpl<K,V> async
protected RedisReactiveCommandsImpl<K,V> reactive
protected MultiOutput<K,V> multi
public StatefulRedisConnectionImpl(RedisChannelWriter<K,V> writer, RedisCodec<K,V> codec, long timeout, TimeUnit unit)
writer
- the channel writercodec
- Codec used to encode/decode keys and values.timeout
- Maximum time to wait for a response.unit
- Unit of time for the timeout.public RedisAsyncCommands<K,V> async()
StatefulRedisConnection
RedisAsyncCommands
API for the current connection. Does not create a new connection.async
in interface StatefulRedisConnection<K,V>
protected RedisAsyncCommandsImpl<K,V> getAsyncCommands()
protected RedisAsyncCommandsImpl<K,V> newRedisAsyncCommandsImpl()
RedisAsyncCommandsImpl
. Can be overriden to extend.public RedisReactiveCommands<K,V> reactive()
StatefulRedisConnection
RedisReactiveCommands
API for the current connection. Does not create a new connection.reactive
in interface StatefulRedisConnection<K,V>
protected RedisReactiveCommandsImpl<K,V> getReactiveCommands()
protected RedisReactiveCommandsImpl<K,V> newRedisReactiveCommandsImpl()
RedisReactiveCommandsImpl
. Can be overriden to extend.public RedisCommands<K,V> sync()
StatefulRedisConnection
RedisCommands
API for the current connection. Does not create a new connection.sync
in interface StatefulRedisConnection<K,V>
public boolean isMulti()
isMulti
in interface StatefulRedisConnection<K,V>
public void activated()
RedisChannelHandler
activated
in class RedisChannelHandler<K,V>
public <T,C extends RedisCommand<K,V,T>> C dispatch(C cmd)
StatefulConnection
dispatch
in interface StatefulConnection<K,V>
dispatch
in class RedisChannelHandler<K,V>
T
- result typeC
- command typecmd
- the Redis commandCopyright © 2016. All rights reserved.