K - Key type.V - Value type.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.| 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 |
| Constructor and Description |
|---|
StatefulRedisConnectionImpl(RedisChannelWriter writer,
PushHandler pushHandler,
RedisCodec<K,V> codec,
Duration timeout)
Initialize a new connection.
|
StatefulRedisConnectionImpl(RedisChannelWriter writer,
PushHandler pushHandler,
RedisCodec<K,V> codec,
Duration timeout,
Supplier<JsonParser> parser)
Initialize a new connection.
|
| Modifier and Type | Method and Description |
|---|---|
void |
activated()
Notification when the connection becomes active (connected).
|
void |
addListener(PushListener listener)
Add a new listener.
|
RedisAsyncCommands<K,V> |
async()
Returns the
RedisAsyncCommands API for the current connection. |
void |
deactivated()
Notification when the connection becomes inactive (disconnected).
|
Collection<RedisCommand<K,V,?>> |
dispatch(Collection<? extends RedisCommand<K,V,?>> commands)
Dispatch multiple command in a single write on the channel.
|
<T> RedisCommand<K,V,T> |
dispatch(RedisCommand<K,V,T> command)
Dispatch a command.
|
RedisCodec<K,V> |
getCodec() |
ConnectionState |
getConnectionState() |
boolean |
isMulti() |
protected RedisAsyncCommandsImpl<K,V> |
newRedisAsyncCommandsImpl()
Create a new instance of
RedisAsyncCommandsImpl. |
protected RedisReactiveCommandsImpl<K,V> |
newRedisReactiveCommandsImpl()
Create a new instance of
RedisReactiveCommandsImpl. |
protected RedisCommands<K,V> |
newRedisSyncCommandsImpl()
Create a new instance of
RedisCommands. |
protected <T> RedisCommand<K,V,T> |
postProcessCommand(RedisCommand<K,V,T> command) |
protected Collection<RedisCommand<K,V,?>> |
postProcessCommands(Collection<RedisCommand<K,V,?>> commands) |
protected <T> RedisCommand<K,V,T> |
preProcessCommand(RedisCommand<K,V,T> command) |
protected Collection<RedisCommand<K,V,?>> |
preProcessCommands(Collection<? extends RedisCommand<K,V,?>> commands) |
RedisReactiveCommands<K,V> |
reactive()
Returns the
RedisReactiveCommands API for the current connection. |
void |
removeListener(PushListener listener)
Remove an existing listener.
|
void |
setAuthenticationHandler(RedisAuthenticationHandler<K,V> handler) |
void |
setClientName(String clientName)
Deprecated.
since 6.0, use
RedisServerAsyncCommands.clientSetname(Object). |
RedisCommands<K,V> |
sync()
Returns the
RedisCommands API for the current connection. |
addListener, addListener, close, closeAsync, flushCommands, getChannelWriter, getConnectionEvents, getOptions, getResources, getTimeout, isClosed, isOpen, registerCloseables, removeListener, setAutoFlushCommands, setOptions, setTimeout, syncHandlerclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaddListener, close, closeAsync, flushCommands, getOptions, getResources, getTimeout, isOpen, removeListener, setAutoFlushCommands, setTimeoutprotected final RedisCodec<K,V> codec
protected final RedisCommands<K,V> sync
protected final RedisAsyncCommandsImpl<K,V> async
protected final RedisReactiveCommandsImpl<K,V> reactive
protected MultiOutput<K,V> multi
public StatefulRedisConnectionImpl(RedisChannelWriter writer, PushHandler pushHandler, RedisCodec<K,V> codec, Duration timeout)
writer - the channel writer.pushHandler - the handler for push notifications.codec - Codec used to encode/decode keys and values.timeout - Maximum time to wait for a response.public StatefulRedisConnectionImpl(RedisChannelWriter writer, PushHandler pushHandler, RedisCodec<K,V> codec, Duration timeout, Supplier<JsonParser> parser)
writer - the channel writer.pushHandler - the handler for push notifications.codec - Codec used to encode/decode keys and values.timeout - Maximum time to wait for a response.parser - the parser to use for JSON commands.public RedisCodec<K,V> getCodec()
getCodec in interface StatefulConnection<K,V>RedisCodec used by this connection.public RedisAsyncCommands<K,V> async()
StatefulRedisConnectionRedisAsyncCommands API for the current connection. Does not create a new connection.async in interface StatefulRedisConnection<K,V>protected RedisCommands<K,V> newRedisSyncCommandsImpl()
RedisCommands. Can be overriden to extend.protected RedisAsyncCommandsImpl<K,V> newRedisAsyncCommandsImpl()
RedisAsyncCommandsImpl. Can be overriden to extend.public RedisReactiveCommands<K,V> reactive()
StatefulRedisConnectionRedisReactiveCommands API for the current connection. Does not create a new connection.reactive in interface StatefulRedisConnection<K,V>protected RedisReactiveCommandsImpl<K,V> newRedisReactiveCommandsImpl()
RedisReactiveCommandsImpl. Can be overriden to extend.public RedisCommands<K,V> sync()
StatefulRedisConnectionRedisCommands API for the current connection. Does not create a new connection.sync in interface StatefulRedisConnection<K,V>public void addListener(PushListener listener)
addListener in interface StatefulRedisConnection<K,V>listener - Listener.public void removeListener(PushListener listener)
removeListener in interface StatefulRedisConnection<K,V>listener - Listener.public boolean isMulti()
isMulti in interface StatefulRedisConnection<K,V>public <T> RedisCommand<K,V,T> dispatch(RedisCommand<K,V,T> command)
StatefulConnectiondispatch in interface StatefulConnection<K,V>dispatch in class RedisChannelHandler<K,V>T - result typecommand - the Redis command.public Collection<RedisCommand<K,V,?>> dispatch(Collection<? extends RedisCommand<K,V,?>> commands)
StatefulConnectiondispatch in interface StatefulConnection<K,V>dispatch in class RedisChannelHandler<K,V>commands - the Redis commands.protected Collection<RedisCommand<K,V,?>> postProcessCommands(Collection<RedisCommand<K,V,?>> commands)
protected <T> RedisCommand<K,V,T> postProcessCommand(RedisCommand<K,V,T> command)
protected Collection<RedisCommand<K,V,?>> preProcessCommands(Collection<? extends RedisCommand<K,V,?>> commands)
protected <T> RedisCommand<K,V,T> preProcessCommand(RedisCommand<K,V,T> command)
@Deprecated public void setClientName(String clientName)
RedisServerAsyncCommands.clientSetname(Object).clientName - public ConnectionState getConnectionState()
public void activated()
RedisChannelHandleractivated in interface ConnectionFacadeactivated in class RedisChannelHandler<K,V>public void deactivated()
RedisChannelHandlerdeactivated in interface ConnectionFacadedeactivated in class RedisChannelHandler<K,V>public void setAuthenticationHandler(RedisAuthenticationHandler<K,V> handler)
Copyright © 2025 lettuce.io. All rights reserved.