Interface RedisConfiguration
- All Known Implementing Classes:
RedisClusterConfiguration
,RedisSentinelConfiguration
,RedisSocketConfiguration
,RedisStandaloneConfiguration
,RedisStaticMasterReplicaConfiguration
public interface RedisConfiguration
Marker interface for configuration classes related to Redis connection setup. As the setup scenarios are quite
diverse instead of struggling with unifying those,
RedisConfiguration
provides means to identify
configurations for the individual purposes.- Since:
- 2.1
- Author:
- Christoph Strobl, Luis De Bello, Vikas Garg
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic interface
Configuration interface suitable for Redis cluster environments.static interface
Configuration interface suitable for single node redis connections using local unix domain socket.static interface
Configuration interface suitable for Redis Sentinel environments.static interface
Configuration interface suitable for Redis master/replica environments with fixed hosts.static interface
RedisConfiguration
part suitable for configurations that may use authentication when connecting.static interface
RedisConfiguration
part suitable for configurations that use a specific database.static interface
RedisConfiguration
part suitable for configurations that use native domain sockets for connecting.static interface
RedisConfiguration
part suitable for configurations that use host/port combinations for connecting.static interface
RedisConfiguration
part suitable for configurations that may use authentication when connecting. -
Method Summary
Modifier and TypeMethodDescriptiondefault Integer
getDatabaseOrElse
(Supplier<Integer> other) Get the configured database index if the currentRedisConfiguration
isdatabase aware
or evaluate and return the value of the givenSupplier
.static Integer
getDatabaseOrElse
(RedisConfiguration configuration, Supplier<Integer> other) static String
getHostOrElse
(RedisConfiguration configuration, Supplier<String> other) default RedisPassword
getPasswordOrElse
(Supplier<RedisPassword> other) Get the configuredRedisPassword
if the currentRedisConfiguration
ispassword aware
or evaluate and return the value of the givenSupplier
.static RedisPassword
getPasswordOrElse
(RedisConfiguration configuration, Supplier<RedisPassword> other) static int
getPortOrElse
(RedisConfiguration configuration, IntSupplier other) static String
getUsernameOrElse
(RedisConfiguration configuration, Supplier<String> other) static boolean
isAuthenticationAware
(RedisConfiguration configuration) static boolean
isClusterConfiguration
(RedisConfiguration configuration) static boolean
isDatabaseIndexAware
(RedisConfiguration configuration) static boolean
isDomainSocketConfiguration
(RedisConfiguration configuration) static boolean
isHostAndPortAware
(RedisConfiguration configuration) static boolean
isSentinelConfiguration
(RedisConfiguration configuration) static boolean
isStaticMasterReplicaConfiguration
(RedisConfiguration configuration)
-
Method Details
-
getDatabaseOrElse
Get the configured database index if the currentRedisConfiguration
isdatabase aware
or evaluate and return the value of the givenSupplier
.- Parameters:
other
- aSupplier
whose result is returned if givenRedisConfiguration
is notdatabase aware
.- Returns:
- never null.
- Throws:
IllegalArgumentException
- ifother
is null.
-
getPasswordOrElse
Get the configuredRedisPassword
if the currentRedisConfiguration
ispassword aware
or evaluate and return the value of the givenSupplier
.- Parameters:
other
- aSupplier
whose result is returned if givenRedisConfiguration
is notpassword aware
.- Returns:
- never null.
- Throws:
IllegalArgumentException
- ifother
is null.
-
isAuthenticationAware
- Parameters:
configuration
- can be null.- Returns:
true
if givenRedisConfiguration
is instance ofRedisConfiguration.WithPassword
.
-
isDatabaseIndexAware
- Parameters:
configuration
- can be null.- Returns:
true
if givenRedisConfiguration
is instance ofRedisConfiguration.WithDatabaseIndex
.
-
isSentinelConfiguration
- Parameters:
configuration
- can be null.- Returns:
true
if givenRedisConfiguration
is instance ofRedisConfiguration.SentinelConfiguration
.
-
isHostAndPortAware
- Parameters:
configuration
- can be null.- Returns:
true
if givenRedisConfiguration
is instance ofRedisConfiguration.WithHostAndPort
.- Since:
- 2.1.6
-
isClusterConfiguration
- Parameters:
configuration
- can be null.- Returns:
true
if givenRedisConfiguration
is instance ofRedisConfiguration.ClusterConfiguration
.
-
isStaticMasterReplicaConfiguration
- Parameters:
configuration
- can be null.- Returns:
true
if givenRedisConfiguration
is instance ofRedisConfiguration.StaticMasterReplicaConfiguration
.
-
isDomainSocketConfiguration
- Parameters:
configuration
- can be null.- Returns:
true
if givenRedisConfiguration
is instance ofRedisConfiguration.DomainSocketConfiguration
.
-
getDatabaseOrElse
static Integer getDatabaseOrElse(@Nullable RedisConfiguration configuration, Supplier<Integer> other) - Parameters:
configuration
- can be null.other
- aSupplier
whose result is returned if givenRedisConfiguration
is notdatabase aware
.- Returns:
- never null.
- Throws:
IllegalArgumentException
- ifother
is null.
-
getUsernameOrElse
@Nullable static String getUsernameOrElse(@Nullable RedisConfiguration configuration, Supplier<String> other) - Parameters:
configuration
- can be null.other
- aSupplier
whose result is returned if givenRedisConfiguration
is notpassword aware
.- Returns:
- can be null.
- Throws:
IllegalArgumentException
- ifother
is null.
-
getPasswordOrElse
static RedisPassword getPasswordOrElse(@Nullable RedisConfiguration configuration, Supplier<RedisPassword> other) - Parameters:
configuration
- can be null.other
- aSupplier
whose result is returned if givenRedisConfiguration
is notpassword aware
.- Returns:
- never null.
- Throws:
IllegalArgumentException
- ifother
is null.
-
getPortOrElse
- Parameters:
configuration
- can be null.other
- aSupplier
whose result is returned if givenRedisConfiguration
is notport aware
.- Returns:
- never null.
- Throws:
IllegalArgumentException
- ifother
is null.- Since:
- 2.1.6
-
getHostOrElse
- Parameters:
configuration
- can be null.other
- aSupplier
whose result is returned if givenRedisConfiguration
is nothost aware
.- Returns:
- never null.
- Throws:
IllegalArgumentException
- ifother
is null.- Since:
- 2.1.6
-