K - Key type.V - Value type.public interface StatefulRedisPubSubConnection<K,V> extends StatefulRedisConnection<K,V>
RedisPubSubListeners.
A ConnectionWatchdog monitors each connection and reconnects automatically until
StatefulConnection.close() is called. Channel and pattern subscriptions are renewed after reconnecting.| Modifier and Type | Method and Description |
|---|---|
void |
addListener(RedisPubSubListener<K,V> listener)
Add a new
listener. |
RedisPubSubAsyncCommands<K,V> |
async()
Returns the
RedisPubSubAsyncCommands API for the current connection. |
default <T> T |
commands(PubSubCommandsFactory<StatefulRedisPubSubConnection<K,V>,T> factory)
Returns the command API created by
factory, bound to this connection. |
RedisPubSubReactiveCommands<K,V> |
reactive()
Deprecated.
since 7.8, use
commands(PubSubCommandsFactory) with RedisPubSubReactiveCommands.factory()
instead; scheduled for removal in a future major release. |
void |
removeListener(RedisPubSubListener<K,V> listener)
Remove an existing
listener. |
RedisPubSubCommands<K,V> |
sync()
Returns the
RedisPubSubCommands API for the current connection. |
addListener, commands, isMulti, removeListeneraddListener, close, closeAsync, dispatch, dispatch, flushCommands, getCodec, getOptions, getResources, getTimeout, isOpen, removeListener, setAutoFlushCommands, setTimeoutRedisPubSubCommands<K,V> sync()
RedisPubSubCommands 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.
sync in interface StatefulRedisConnection<K,V>RedisPubSubAsyncCommands<K,V> async()
RedisPubSubAsyncCommands 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.
async in interface StatefulRedisConnection<K,V>@Deprecated RedisPubSubReactiveCommands<K,V> reactive()
commands(PubSubCommandsFactory) with RedisPubSubReactiveCommands.factory()
instead; scheduled for removal in a future major release.RedisPubSubReactiveCommands API for the current connection. Does not create a new connection.reactive in interface StatefulRedisConnection<K,V>void addListener(RedisPubSubListener<K,V> listener)
listener.listener - the listener, must not be null.void removeListener(RedisPubSubListener<K,V> listener)
listener.listener - the listener, must not be null.default <T> T commands(PubSubCommandsFactory<StatefulRedisPubSubConnection<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.