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 TypeMethodDescriptionstatic IntegergetDatabaseOrElse(@Nullable RedisConfiguration configuration, Supplier<Integer> other) default IntegergetDatabaseOrElse(Supplier<Integer> other) Get the configured database index if the currentRedisConfigurationisdatabase awareor evaluate and return the value of the givenSupplier.static StringgetHostOrElse(@Nullable RedisConfiguration configuration, Supplier<String> other) static RedisPasswordgetPasswordOrElse(@Nullable RedisConfiguration configuration, Supplier<RedisPassword> other) default RedisPasswordgetPasswordOrElse(Supplier<RedisPassword> other) Get the configuredRedisPasswordif the currentRedisConfigurationispassword awareor evaluate and return the value of the givenSupplier.static intgetPortOrElse(@Nullable RedisConfiguration configuration, IntSupplier other) static @Nullable StringgetUsernameOrElse(@Nullable RedisConfiguration configuration, Supplier<@Nullable String> other) static booleanisAuthenticationAware(@Nullable RedisConfiguration configuration) static booleanisClusterConfiguration(@Nullable RedisConfiguration configuration) static booleanisDatabaseIndexAware(@Nullable RedisConfiguration configuration) static booleanisDomainSocketConfiguration(@Nullable RedisConfiguration configuration) static booleanisHostAndPortAware(@Nullable RedisConfiguration configuration) static booleanisSentinelConfiguration(@Nullable RedisConfiguration configuration) static booleanisStaticMasterReplicaConfiguration(@Nullable 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
@Contract("null -> false") static boolean isAuthenticationAware(@Nullable RedisConfiguration configuration) - Parameters:
configuration- can be null.- Returns:
trueif givenRedisConfigurationis instance ofRedisConfiguration.WithPassword.
-
isDatabaseIndexAware
@Contract("null -> false") static boolean isDatabaseIndexAware(@Nullable RedisConfiguration configuration) - Parameters:
configuration- can be null.- Returns:
trueif givenRedisConfigurationis instance ofRedisConfiguration.WithDatabaseIndex.
-
isSentinelConfiguration
@Contract("null -> false") static boolean isSentinelConfiguration(@Nullable RedisConfiguration configuration) - Parameters:
configuration- can be null.- Returns:
trueif givenRedisConfigurationis instance ofRedisConfiguration.SentinelConfiguration.
-
isHostAndPortAware
@Contract("null -> false") static boolean isHostAndPortAware(@Nullable RedisConfiguration configuration) - Parameters:
configuration- can be null.- Returns:
trueif givenRedisConfigurationis instance ofRedisConfiguration.WithHostAndPort.- Since:
- 2.1.6
-
isClusterConfiguration
@Contract("null -> false") static boolean isClusterConfiguration(@Nullable RedisConfiguration configuration) - Parameters:
configuration- can be null.- Returns:
trueif givenRedisConfigurationis instance ofRedisConfiguration.ClusterConfiguration.
-
isStaticMasterReplicaConfiguration
@Contract("null -> false") static boolean isStaticMasterReplicaConfiguration(@Nullable RedisConfiguration configuration) - Parameters:
configuration- can be null.- Returns:
trueif givenRedisConfigurationis instance ofRedisConfiguration.StaticMasterReplicaConfiguration.
-
isDomainSocketConfiguration
@Contract("null -> false") static boolean isDomainSocketConfiguration(@Nullable RedisConfiguration configuration) - 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
static @Nullable String getUsernameOrElse(@Nullable RedisConfiguration configuration, Supplier<@Nullable 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
-