Class RedisConnectionUtil
java.lang.Object
io.micronaut.configuration.lettuce.RedisConnectionUtil
Internal utility methods for configuration.
- Since:
- 1.0
- Author:
- Graeme Rocher, Illia Kovalov
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic @NonNull io.lettuce.core.AbstractRedisClientfindClient(io.micronaut.context.BeanLocator beanLocator, Optional<String> serverName, String errorMessage) Utility method for establishing a redis connection.static <T> Optional<T> findNamedOrDefaultBean(io.micronaut.context.BeanLocator beanLocator, Class<T> beanType, Optional<String> serverName) Utility method to find a named bean first and fallback to the default bean.static io.lettuce.core.api.StatefulConnectionfindRedisConnection(io.micronaut.context.BeanLocator beanLocator, Optional<String> serverName, String errorMessage) Utility method for establishing a redis connection.static io.lettuce.core.api.StatefulConnection<byte[], byte[]> openBytesRedisConnection(io.micronaut.context.BeanLocator beanLocator, Optional<String> serverName, String errorMessage) Utility method for opening a new bytes redis connection.static io.lettuce.core.pubsub.StatefulRedisPubSubConnection<byte[], byte[]> openBytesRedisPubSubConnection(io.micronaut.context.BeanLocator beanLocator, Optional<String> serverName, String errorMessage) Utility method for opening a new bytes pub/sub redis connection.
-
Constructor Details
-
RedisConnectionUtil
public RedisConnectionUtil()
-
-
Method Details
-
findClient
public static @NonNull io.lettuce.core.AbstractRedisClient findClient(io.micronaut.context.BeanLocator beanLocator, Optional<String> serverName, String errorMessage) Utility method for establishing a redis connection.- Parameters:
beanLocator- The bean locator to useserverName- The server name to useerrorMessage- The error message to use if the connection can't be found- Returns:
- The connection
- Throws:
io.micronaut.context.exceptions.ConfigurationException- If the connection cannot be found
-
findRedisConnection
public static io.lettuce.core.api.StatefulConnection findRedisConnection(io.micronaut.context.BeanLocator beanLocator, Optional<String> serverName, String errorMessage) Utility method for establishing a redis connection.- Parameters:
beanLocator- The bean locator to useserverName- The server name to useerrorMessage- The error message to use if the connection can't be found- Returns:
- The connection
- Throws:
io.micronaut.context.exceptions.ConfigurationException- If the connection cannot be found
-
findNamedOrDefaultBean
public static <T> Optional<T> findNamedOrDefaultBean(io.micronaut.context.BeanLocator beanLocator, Class<T> beanType, Optional<String> serverName) Utility method to find a named bean first and fallback to the default bean.- Type Parameters:
T- Bean type- Parameters:
beanLocator- Bean locatorbeanType- Bean typeserverName- Server name- Returns:
- The matching bean if available
-
openBytesRedisConnection
public static io.lettuce.core.api.StatefulConnection<byte[],byte[]> openBytesRedisConnection(io.micronaut.context.BeanLocator beanLocator, Optional<String> serverName, String errorMessage) Utility method for opening a new bytes redis connection.- Parameters:
beanLocator- The bean locator to useserverName- The server name to useerrorMessage- The error message to use if the connection can't be found- Returns:
- The connection
- Throws:
io.micronaut.context.exceptions.ConfigurationException- If the connection cannot be found
-
openBytesRedisPubSubConnection
public static io.lettuce.core.pubsub.StatefulRedisPubSubConnection<byte[],byte[]> openBytesRedisPubSubConnection(io.micronaut.context.BeanLocator beanLocator, Optional<String> serverName, String errorMessage) Utility method for opening a new bytes pub/sub redis connection.- Parameters:
beanLocator- The bean locator to useserverName- The server name to useerrorMessage- The error message to use if the connection can't be found- Returns:
- The pub/sub connection
- Throws:
io.micronaut.context.exceptions.ConfigurationException- If the connection cannot be found
-