-
Notifications
You must be signed in to change notification settings - Fork 985
Stateful connections (4.0)
lettuce 4.0 introduced StatefulConnection
interfaces to separate connection resources from the particular API. Every API operates on a stateful connection that maintains the state (authentication, transactional/multi-status, selected database, read-only/read-write state). This state is restored after the connection reconnects. All async, sync and reactive API's operate on the underlying connection. If you close for example the connection using the sync API, the same connection is no longer usable over the async or reactive API. Multiple connections (multiple calls to connect()
other connect...()
methods) create multiple connections that are isolated and behave independently from each other.
You can obtain a stateful connection from an existing connection by calling getStatefulConnection()
on the async, sync or reactive API. Depending on the API (standalone, sentinel, pubsub or cluster) you will get different types (StatefulRedisClusterConnection
, StatefulRedisConnection
, ...).
A stateful connection provides different APIs: sync, async and reactive. The API objects should not be closed unless you plan to close the connection. Closing the API will close the underlying connection. Retrieving the API instance instead of reusing is the preferred style since the API instances are cached anyways.
Lettuce documentation was moved to https://redis.github.io/lettuce/overview/
Intro
Getting started
- Getting started
- Redis URI and connection details
- Basic usage
- Asynchronous API
- Reactive API
- Publish/Subscribe
- Transactions/Multi
- Scripting and Functions
- Redis Command Interfaces
- FAQ
HA and Sharding
Advanced usage
- Configuring Client resources
- Client Options
- Dynamic Command Interfaces
- SSL Connections
- Native Transports
- Unix Domain Sockets
- Streaming API
- Events
- Command Latency Metrics
- Tracing
- Stateful Connections
- Pipelining/Flushing
- Connection Pooling
- Graal Native Image
- Custom commands
Integration and Extension
Internals