K - Key type.V - Value type.public interface StatefulRedisConnection<K,V> extends StatefulConnection<K,V>
StatefulRedisConnection.
A ConnectionWatchdog monitors each connection and reconnects automatically until StatefulConnection.close() is called. All
pending commands will be (re)sent after successful reconnection.| Modifier and Type | Method and Description |
|---|---|
void |
addListener(PushListener listener)
Add a new
listener to consume push messages. |
RedisAsyncCommands<K,V> |
async()
Returns the
RedisAsyncCommands API for the current connection. |
default <T> T |
commands(CommandsFactory<StatefulRedisConnection<K,V>,T> factory)
Returns the command API created by
factory, bound to this connection. |
boolean |
isMulti() |
RedisReactiveCommands<K,V> |
reactive()
Deprecated.
since 7.8, use
commands(CommandsFactory) with RedisReactiveCommands.factory() instead;
scheduled for removal in a future major release. |
void |
removeListener(PushListener listener)
Remove an existing
listener. |
RedisCommands<K,V> |
sync()
Returns the
RedisCommands API for the current connection. |
addListener, close, closeAsync, dispatch, dispatch, flushCommands, getCodec, getOptions, getResources, getTimeout, isOpen, removeListener, setAutoFlushCommands, setTimeoutboolean isMulti()
RedisCommands<K,V> sync()
RedisCommands API for the current connection. Does not create a new connection.
Note: this accessor is scheduled for removal in a future major release; a commands(...)-based replacement is
planned.
RedisAsyncCommands<K,V> async()
RedisAsyncCommands API for the current connection. Does not create a new connection.
Note: this accessor is scheduled for removal in a future major release; a commands(...)-based replacement is
planned.
@Deprecated RedisReactiveCommands<K,V> reactive()
commands(CommandsFactory) with RedisReactiveCommands.factory() instead;
scheduled for removal in a future major release.RedisReactiveCommands API for the current connection. Does not create a new connection.void addListener(PushListener listener)
listener to consume push messages.listener - the listener, must not be null.void removeListener(PushListener listener)
listener.listener - the listener, must not be null.default <T> T commands(CommandsFactory<StatefulRedisConnection<K,V>,T> factory)
factory, bound to this connection. Does not create a new connection.
The command API is created once per connection and cached; calling this method again with the same factory
returns the same instance.
T - the command API typefactory - the command API factory, must not be nullUnsupportedOperationException - if the connection implementation does not override this method. The default is
provided only for source compatibility in Lettuce 7.x and becomes an abstract method in Lettuce 8.0.Copyright © 2026 lettuce.io. All rights reserved.