Package io.lettuce.core.pubsub
Interface StatefulRedisPubSubConnection<K,V>
-
- Type Parameters:
K
- Key type.V
- Value type.
- All Superinterfaces:
AsyncCloseable
,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 registeredRedisPubSubListener
s. AConnectionWatchdog
monitors each connection and reconnects automatically untilStatefulConnection.close()
is called. Channel and pattern subscriptions are renewed after reconnecting.- Since:
- 4.0
- Author:
- Mark Paluch
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
addListener(RedisPubSubListener<K,V> listener)
Add a newlistener
.RedisPubSubAsyncCommands<K,V>
async()
Returns theRedisPubSubAsyncCommands
API for the current connection.RedisPubSubReactiveCommands<K,V>
reactive()
Returns theRedisPubSubReactiveCommands
API for the current connection.void
removeListener(RedisPubSubListener<K,V> listener)
Remove an existinglistener
.RedisPubSubCommands<K,V>
sync()
Returns theRedisPubSubCommands
API for the current connection.-
Methods inherited from interface io.lettuce.core.api.StatefulConnection
addListener, close, closeAsync, dispatch, dispatch, flushCommands, getOptions, getResources, getTimeout, isOpen, removeListener, reset, setAutoFlushCommands, setTimeout
-
Methods inherited from interface io.lettuce.core.api.StatefulRedisConnection
addListener, isMulti, removeListener
-
-
-
-
Method Detail
-
sync
RedisPubSubCommands<K,V> sync()
Returns theRedisPubSubCommands
API for the current connection. Does not create a new connection.- Specified by:
sync
in interfaceStatefulRedisConnection<K,V>
- Returns:
- the synchronous API for the underlying connection.
-
async
RedisPubSubAsyncCommands<K,V> async()
Returns theRedisPubSubAsyncCommands
API for the current connection. Does not create a new connection.- Specified by:
async
in interfaceStatefulRedisConnection<K,V>
- Returns:
- the asynchronous API for the underlying connection.
-
reactive
RedisPubSubReactiveCommands<K,V> reactive()
Returns theRedisPubSubReactiveCommands
API for the current connection. Does not create a new connection.- Specified by:
reactive
in interfaceStatefulRedisConnection<K,V>
- Returns:
- the reactive API for the underlying connection.
-
addListener
void addListener(RedisPubSubListener<K,V> listener)
Add a newlistener
.- Parameters:
listener
- the listener, must not benull
.
-
removeListener
void removeListener(RedisPubSubListener<K,V> listener)
Remove an existinglistener
.- Parameters:
listener
- the listener, must not benull
.
-
-