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
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceConfiguration interface suitable for Redis cluster environments.static interfaceConfiguration interface suitable for single node redis connections using local unix domain socket.static interfaceConfiguration interface suitable for Redis Sentinel environments.static interfaceConfiguration interface suitable for Redis master/replica environments with fixed hosts.static interfaceRedisConfigurationpart suitable for configurations that may use authentication when connecting.static interfaceRedisConfigurationpart suitable for configurations that use a specific database.static interfaceRedisConfigurationpart suitable for configurations that use native domain sockets for connecting.static interfaceRedisConfigurationpart suitable for configurations that use host/port combinations for connecting.static interfaceRedisConfigurationpart suitable for configurations that may use authentication when connecting. -
Method Summary
Modifier and TypeMethodDescriptiondefault IntegergetDatabaseOrElse(Supplier<Integer> other) Get the configured database index if the currentRedisConfigurationisdatabase awareor evaluate and return the value of the givenSupplier.static IntegergetDatabaseOrElse(RedisConfiguration configuration, Supplier<Integer> other) static StringgetHostOrElse(RedisConfiguration configuration, Supplier<String> other) default RedisPasswordgetPasswordOrElse(Supplier<RedisPassword> other) Get the configuredRedisPasswordif the currentRedisConfigurationispassword awareor evaluate and return the value of the givenSupplier.static RedisPasswordgetPasswordOrElse(RedisConfiguration configuration, Supplier<RedisPassword> other) static intgetPortOrElse(RedisConfiguration configuration, IntSupplier other) static StringgetUsernameOrElse(RedisConfiguration configuration, Supplier<String> other) static booleanisAuthenticationAware(RedisConfiguration configuration) static booleanisClusterConfiguration(RedisConfiguration configuration) static booleanisDatabaseIndexAware(RedisConfiguration configuration) static booleanisDomainSocketConfiguration(RedisConfiguration configuration) static booleanisHostAndPortAware(RedisConfiguration configuration) static booleanisSentinelConfiguration(RedisConfiguration configuration) static booleanisStaticMasterReplicaConfiguration(RedisConfiguration configuration)
-
Method Details
-
getDatabaseOrElse
Get the configured database index if the currentRedisConfigurationisdatabase awareor evaluate and return the value of the givenSupplier.- Parameters:
other- aSupplierwhose result is returned if givenRedisConfigurationis notdatabase aware.- Returns:
- never null.
- Throws:
IllegalArgumentException- ifotheris null.
-
getPasswordOrElse
Get the configuredRedisPasswordif the currentRedisConfigurationispassword awareor evaluate and return the value of the givenSupplier.- Parameters:
other- aSupplierwhose result is returned if givenRedisConfigurationis notpassword aware.- Returns:
- never null.
- Throws:
IllegalArgumentException- ifotheris null.
-
isAuthenticationAware
- Parameters:
configuration- can be null.- Returns:
trueif givenRedisConfigurationis instance ofRedisConfiguration.WithPassword.
-
isDatabaseIndexAware
- Parameters:
configuration- can be null.- Returns:
trueif givenRedisConfigurationis instance ofRedisConfiguration.WithDatabaseIndex.
-
isSentinelConfiguration
- Parameters:
configuration- can be null.- Returns:
trueif givenRedisConfigurationis instance ofRedisConfiguration.SentinelConfiguration.
-
isHostAndPortAware
- Parameters:
configuration- can be null.- Returns:
trueif givenRedisConfigurationis instance ofRedisConfiguration.WithHostAndPort.- Since:
- 2.1.6
-
isClusterConfiguration
- Parameters:
configuration- can be null.- Returns:
trueif givenRedisConfigurationis instance ofRedisConfiguration.ClusterConfiguration.
-
isStaticMasterReplicaConfiguration
- Parameters:
configuration- can be null.- Returns:
trueif givenRedisConfigurationis instance ofRedisConfiguration.StaticMasterReplicaConfiguration.
-
isDomainSocketConfiguration
- Parameters:
configuration- can be null.- Returns:
trueif givenRedisConfigurationis instance ofRedisConfiguration.DomainSocketConfiguration.
-
getDatabaseOrElse
static Integer getDatabaseOrElse(@Nullable RedisConfiguration configuration, Supplier<Integer> other) - Parameters:
configuration- can be null.other- aSupplierwhose result is returned if givenRedisConfigurationis notdatabase aware.- Returns:
- never null.
- Throws:
IllegalArgumentException- ifotheris null.
-
getUsernameOrElse
@Nullable static String getUsernameOrElse(@Nullable RedisConfiguration configuration, Supplier<String> other) - Parameters:
configuration- can be null.other- aSupplierwhose result is returned if givenRedisConfigurationis notpassword aware.- Returns:
- can be null.
- Throws:
IllegalArgumentException- ifotheris null.
-
getPasswordOrElse
static RedisPassword getPasswordOrElse(@Nullable RedisConfiguration configuration, Supplier<RedisPassword> other) - Parameters:
configuration- can be null.other- aSupplierwhose result is returned if givenRedisConfigurationis notpassword aware.- Returns:
- never null.
- Throws:
IllegalArgumentException- ifotheris null.
-
getPortOrElse
- Parameters:
configuration- can be null.other- aSupplierwhose result is returned if givenRedisConfigurationis notport aware.- Returns:
- never null.
- Throws:
IllegalArgumentException- ifotheris null.- Since:
- 2.1.6
-
getHostOrElse
- Parameters:
configuration- can be null.other- aSupplierwhose result is returned if givenRedisConfigurationis nothost aware.- Returns:
- never null.
- Throws:
IllegalArgumentException- ifotheris null.- Since:
- 2.1.6
-