- Type Parameters:
K- Key type.V- Value type.
- All Superinterfaces:
AsyncCloseable,AutoCloseable,StatefulConnection<K,V>
- All Known Subinterfaces:
StatefulRedisClusterPubSubConnection<K,V>,StatefulRedisMasterReplicaConnection<K,V>,StatefulRedisMasterSlaveConnection<K,V>,StatefulRedisPubSubConnection<K,V>
- All Known Implementing Classes:
StatefulRedisConnectionImpl,StatefulRedisPubSubConnectionImpl
public interface StatefulRedisConnection<K,V> extends StatefulConnection<K,V>
A thread-safe connection to a redis server. Multiple threads may share one
StatefulRedisConnection.
A ConnectionWatchdog monitors each connection and reconnects automatically until StatefulConnection.close() is called. All
pending commands will be (re)sent after successful reconnection.- Since:
- 4.0
- Author:
- Mark Paluch
-
Method Summary
Modifier and Type Method Description voidaddListener(PushListener listener)Add a newlistenerto consume push messages.RedisAsyncCommands<K,V>async()Returns theRedisAsyncCommandsAPI for the current connection.booleanisMulti()RedisReactiveCommands<K,V>reactive()Returns theRedisReactiveCommandsAPI for the current connection.voidremoveListener(PushListener listener)Remove an existinglistener.RedisCommands<K,V>sync()Returns theRedisCommandsAPI for the current connection.Methods inherited from interface io.lettuce.core.api.StatefulConnection
close, closeAsync, dispatch, dispatch, flushCommands, getOptions, getResources, getTimeout, isOpen, reset, setAutoFlushCommands, setTimeout
-
Method Details
-
isMulti
boolean isMulti()- Returns:
- true, if the connection is within a transaction.
-
sync
RedisCommands<K,V> sync()Returns theRedisCommandsAPI for the current connection. Does not create a new connection.- Returns:
- the synchronous API for the underlying connection.
-
async
RedisAsyncCommands<K,V> async()Returns theRedisAsyncCommandsAPI for the current connection. Does not create a new connection.- Returns:
- the asynchronous API for the underlying connection.
-
reactive
RedisReactiveCommands<K,V> reactive()Returns theRedisReactiveCommandsAPI for the current connection. Does not create a new connection.- Returns:
- the reactive API for the underlying connection.
-
addListener
Add a newlistenerto consume push messages.- Parameters:
listener- the listener, must not benull.- Since:
- 6.0
-
removeListener
Remove an existinglistener.- Parameters:
listener- the listener, must not benull.- Since:
- 6.0
-