- Type Parameters:
K- Key type.V- Value type.
- All Superinterfaces:
AsyncCloseable,AutoCloseable,StatefulConnection<K,V>,StatefulRedisConnection<K,V>
- All Known Subinterfaces:
StatefulRedisClusterPubSubConnection<K,V>
- All Known Implementing Classes:
StatefulRedisPubSubConnectionImpl
public interface StatefulRedisPubSubConnection<K,V> extends StatefulRedisConnection<K,V>
An asynchronous thread-safe pub/sub connection to a redis server. After one or more channels are subscribed to only pub/sub
related commands or QUIT may be called.
Incoming messages and results of the subscribe/unsubscribe calls will be passed to all registered
RedisPubSubListeners.
A ConnectionWatchdog monitors each connection and reconnects automatically until
StatefulConnection.close() is called. Channel and pattern subscriptions are renewed after reconnecting.- Since:
- 4.0
- Author:
- Mark Paluch
-
Method Summary
Modifier and Type Method Description voidaddListener(RedisPubSubListener<K,V> listener)Add a newlistener.RedisPubSubAsyncCommands<K,V>async()Returns theRedisPubSubAsyncCommandsAPI for the current connection.RedisPubSubReactiveCommands<K,V>reactive()Returns theRedisPubSubReactiveCommandsAPI for the current connection.voidremoveListener(RedisPubSubListener<K,V> listener)Remove an existinglistener.RedisPubSubCommands<K,V>sync()Returns theRedisPubSubCommandsAPI for the current connection.Methods inherited from interface io.lettuce.core.api.StatefulConnection
close, closeAsync, dispatch, dispatch, flushCommands, getOptions, getResources, getTimeout, isOpen, reset, setAutoFlushCommands, setTimeoutMethods inherited from interface io.lettuce.core.api.StatefulRedisConnection
addListener, isMulti, removeListener
-
Method Details
-
sync
RedisPubSubCommands<K,V> sync()Returns theRedisPubSubCommandsAPI for the current connection. Does not create a new connection.- Specified by:
syncin interfaceStatefulRedisConnection<K,V>- Returns:
- the synchronous API for the underlying connection.
-
async
RedisPubSubAsyncCommands<K,V> async()Returns theRedisPubSubAsyncCommandsAPI for the current connection. Does not create a new connection.- Specified by:
asyncin interfaceStatefulRedisConnection<K,V>- Returns:
- the asynchronous API for the underlying connection.
-
reactive
RedisPubSubReactiveCommands<K,V> reactive()Returns theRedisPubSubReactiveCommandsAPI for the current connection. Does not create a new connection.- Specified by:
reactivein interfaceStatefulRedisConnection<K,V>- Returns:
- the reactive API for the underlying connection.
-
addListener
Add a newlistener.- Parameters:
listener- the listener, must not benull.
-
removeListener
Remove an existinglistener.- Parameters:
listener- the listener, must not benull.
-