@Experimental public interface BaseRedisMultiDbConnection extends Closeable
| Modifier and Type | Method and Description |
|---|---|
void |
addDatabase(DatabaseConfig databaseConfig)
Add a new database to the multi-database connection.
|
void |
addDatabase(RedisURI redisURI,
float weight)
Add a new database to the multi-database connection.
|
RedisDatabase |
getCurrentDatabase()
Get the current database.
|
RedisURI |
getCurrentEndpoint()
Get the current database endpoint.
|
RedisDatabase |
getDatabase(RedisURI endpoint)
Get the
RedisDatabase for a specific endpoint. |
Iterable<RedisURI> |
getEndpoints()
Get all available database endpoints.
|
boolean |
isHealthy(RedisURI endpoint)
Check if an endpoint is healthy (health status is HEALTHY and circuit breaker is CLOSED).
|
void |
removeDatabase(RedisURI redisURI)
Remove a database from the multi-database connection.
|
void |
switchTo(RedisURI redisURI)
Switch to a different database.
|
void switchTo(RedisURI redisURI)
This method performs a thread-safe switch to the specified database endpoint. If the target database is already the current database, this is a no-op. The method verifies that the target database is healthy and has a closed circuit breaker before switching.
redisURI - the Redis URI of the database to switch to, must not be nullIllegalArgumentException - if the database endpoint is not registered in the connection mapIllegalStateException - if the requested database is unhealthy or circuit breaker is open, or if the requested
database is a different instance than registered in connection map but with the same target endpoint/uri, or if
the switch operation failsUnsupportedOperationException - if the source or destination endpoint cannot be locatedRedisURI getCurrentEndpoint()
RedisDatabase getCurrentDatabase()
Iterable<RedisURI> getEndpoints()
boolean isHealthy(RedisURI endpoint)
endpoint - the Redis endpoint URIIllegalArgumentException - if the endpoint is not knownRedisDatabase getDatabase(RedisURI endpoint)
RedisDatabase for a specific endpoint.endpoint - the Redis endpoint URIRedisDatabase for the endpointIllegalArgumentException - if the endpoint is not knownvoid addDatabase(RedisURI redisURI, float weight)
redisURI - the Redis URI for the new database, must not be nullweight - the weight for endpoint priority, must be greater than 0IllegalArgumentException - if the database already exists or parameters are invalidvoid addDatabase(DatabaseConfig databaseConfig)
databaseConfig - the database configuration, must not be nullIllegalArgumentException - if the database already exists or configuration is invalidvoid removeDatabase(RedisURI redisURI)
redisURI - the Redis URI of the database to remove, must not be nullIllegalArgumentException - if the database does not existUnsupportedOperationException - if attempting to remove the currently active databaseCopyright © 2026 lettuce.io. All rights reserved.