Package com.ohalee.database.redis
Class RedisProvider
java.lang.Object
com.ohalee.database.redis.RedisProvider
- All Implemented Interfaces:
com.ohalee.database.api.DatabaseProvider<io.lettuce.core.api.StatefulRedisConnection<String,String>>
public class RedisProvider
extends Object
implements com.ohalee.database.api.DatabaseProvider<io.lettuce.core.api.StatefulRedisConnection<String,String>>
Implementation of
DatabaseProvider for Redis using the Lettuce
client.
This provider manages a RedisClient and a connection pool.
It also supports a separate Pub/Sub connection.
-
Constructor Summary
ConstructorsConstructorDescriptionRedisProvider(RedisCredentials credentials) Creates a new RedisProvider with the given credentials. -
Method Summary
Modifier and TypeMethodDescriptionvoidconnect()voidGets the dedicated Pub/Sub connection.withClientOptions(io.lettuce.core.ClientOptions clientOptions) Sets theClientOptionsto be used by the RedisClient.withClientResources(io.lettuce.core.resource.ClientResources clientResources) Sets theClientResourcesto be used by the RedisClient.io.lettuce.core.RedisURIwithRedisURI(io.lettuce.core.RedisURI redisURI) Sets a customRedisURIto be used by the RedisClient.
-
Constructor Details
-
RedisProvider
Creates a new RedisProvider with the given credentials.- Parameters:
credentials- The Redis credentials.
-
-
Method Details
-
withRedisURI
public io.lettuce.core.RedisURI withRedisURI(io.lettuce.core.RedisURI redisURI) Sets a customRedisURIto be used by the RedisClient. Must be called beforeconnect().- Parameters:
redisURI- The RedisURI to use.- Returns:
- The RedisURI set.
-
withClientResources
Sets theClientResourcesto be used by the RedisClient. Must be called beforeconnect().- Parameters:
clientResources- The client resources to use.
-
withClientOptions
Sets theClientOptionsto be used by the RedisClient. Must be called beforeconnect().- Parameters:
clientOptions- The client options to use.
-
connect
public void connect() -
disconnect
public void disconnect() -
getConnection
-
pubSubConnection
Gets the dedicated Pub/Sub connection.- Returns:
- The Pub/Sub connection.
-