Package com.redis.lettucemod
Class RedisModulesClient
java.lang.Object
io.lettuce.core.AbstractRedisClient
io.lettuce.core.RedisClient
com.redis.lettucemod.RedisModulesClient
- All Implemented Interfaces:
AutoCloseable
public class RedisModulesClient
extends io.lettuce.core.RedisClient
A scalable and thread-safe client for
Redis Modules supporting synchronous,
asynchronous and reactive execution models. Multiple threads may share one
connection if they avoid blocking and transactional operations such as BLPOP
and MULTI/EXEC.
RedisModulesClient can be used with:
- Redis Standalone
RedisModulesClient is an expensive resource. It holds a set of
netty's EventLoopGroup's that use multiple threads.
Reuse this instance as much as possible or share a ClientResources
instance amongst multiple client instances.
- Author:
- Julien Ruaux
- See Also:
-
RedisURIStatefulRedisModulesConnectionRedisFutureMonoFluxRedisCodecClientOptionsClientResourcesMasterReplica
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final io.lettuce.core.ClientOptionsstatic final io.lettuce.core.protocol.ProtocolVersionFields inherited from class io.lettuce.core.AbstractRedisClient
channels, closeableResources, connectionEvents -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCreates a uri-less RedisModulesClient.protectedRedisModulesClient(io.lettuce.core.resource.ClientResources clientResources, io.lettuce.core.RedisURI redisURI) -
Method Summary
Modifier and TypeMethodDescriptionstatic RedisModulesClientBuilderbuilder()connect()Open a new connection to a Redis server that treats keys and values as UTF-8 strings.<K,V> StatefulRedisModulesConnection<K, V> connect(io.lettuce.core.codec.RedisCodec<K, V> codec) Open a new connection to a Redis server.<K,V> StatefulRedisModulesConnection<K, V> connect(io.lettuce.core.codec.RedisCodec<K, V> codec, io.lettuce.core.RedisURI redisURI) Open a new connection to a Redis server using the suppliedRedisURIand the suppliedcodecto encode/decode keys.connect(io.lettuce.core.RedisURI redisURI) Open a new connection to a Redis server using the suppliedRedisURIthat treats keys and values as UTF-8 strings.static RedisModulesClientcreate()Creates a uri-less RedisModulesClient with defaultClientResources.static RedisModulesClientcreate(io.lettuce.core.RedisURI redisURI) Create a new client that connects to the supplieduriwith defaultClientResources.static RedisModulesClientcreate(io.lettuce.core.resource.ClientResources clientResources) Creates a uri-less RedisModulesClient with sharedClientResources.static RedisModulesClientcreate(io.lettuce.core.resource.ClientResources clientResources, io.lettuce.core.RedisURI redisURI) Create a new client that connects to the supplieduriwith sharedClientResources.static RedisModulesClientCreate a new client that connects to the supplied uri with sharedClientResources.You need to shut down theClientResourcesupon shutting down your application.static RedisModulesClientCreate a new client that connects to the supplied uri with defaultClientResources.static <B extends io.lettuce.core.ClientOptions.Builder>
BdefaultClientOptions(B builder) protected <K,V> StatefulRedisModulesConnectionImpl<K, V> newStatefulRedisConnection(io.lettuce.core.RedisChannelWriter channelWriter, io.lettuce.core.protocol.PushHandler pushHandler, io.lettuce.core.codec.RedisCodec<K, V> codec, Duration timeout) Create a new instance ofStatefulRedisModulesConnectionImplor a subclass.static RedisURIBuilderMethods inherited from class io.lettuce.core.RedisClient
connectAsync, connectPubSub, connectPubSub, connectPubSub, connectPubSub, connectPubSubAsync, connectSentinel, connectSentinel, connectSentinel, connectSentinel, connectSentinelAsync, getSocketAddress, newStatefulRedisPubSubConnection, newStatefulRedisSentinelConnection, newStringStringCodec, setOptionsMethods inherited from class io.lettuce.core.AbstractRedisClient
addListener, addListener, channelType, close, connectionBuilder, connectionBuilder, createHandshake, getChannelCount, getCommandListeners, getConnection, getConnection, getDefaultTimeout, getOptions, getResourceCount, getResources, initializeChannelAsync, removeListener, removeListener, setDefaultTimeout, setDefaultTimeout, shutdown, shutdown, shutdown, shutdownAsync, shutdownAsync
-
Field Details
-
DEFAULT_PROTOCOL_VERSION
public static final io.lettuce.core.protocol.ProtocolVersion DEFAULT_PROTOCOL_VERSION -
DEFAULT_CLIENT_OPTIONS
public static final io.lettuce.core.ClientOptions DEFAULT_CLIENT_OPTIONS
-
-
Constructor Details
-
RedisModulesClient
protected RedisModulesClient(io.lettuce.core.resource.ClientResources clientResources, io.lettuce.core.RedisURI redisURI) -
RedisModulesClient
protected RedisModulesClient()Creates a uri-less RedisModulesClient. You can connect to different Redis servers but you must supply aRedisURIon connecting. Methods without having aRedisURIwill fail with aIllegalStateException. Non-private constructor to makeRedisModulesClientproxyable.
-
-
Method Details
-
defaultClientOptions
public static <B extends io.lettuce.core.ClientOptions.Builder> B defaultClientOptions(B builder) -
create
Creates a uri-less RedisModulesClient with defaultClientResources. You can connect to different Redis servers but you must supply aRedisURIon connecting. Methods without having aRedisURIwill fail with aIllegalStateException.- Returns:
- a new instance of
RedisModulesClient
-
create
Create a new client that connects to the supplieduriwith defaultClientResources. You can connect to different Redis servers but you must supply aRedisURIon connecting.- Parameters:
redisURI- the Redis URI, must not benull- Returns:
- a new instance of
RedisModulesClient
-
create
Create a new client that connects to the supplied uri with defaultClientResources. You can connect to different Redis servers but you must supply aRedisURIon connecting.- Parameters:
uri- the Redis URI, must not benull- Returns:
- a new instance of
RedisModulesClient
-
create
Creates a uri-less RedisModulesClient with sharedClientResources. You need to shut down theClientResourcesupon shutting down your application. You can connect to different Redis servers but you must supply aRedisURIon connecting. Methods without having aRedisURIwill fail with aIllegalStateException.- Parameters:
clientResources- the client resources, must not benull- Returns:
- a new instance of
RedisModulesClient
-
create
public static RedisModulesClient create(io.lettuce.core.resource.ClientResources clientResources, String uri) Create a new client that connects to the supplied uri with sharedClientResources.You need to shut down theClientResourcesupon shutting down your application. You can connect to different Redis servers but you must supply aRedisURIon connecting.- Parameters:
clientResources- the client resources, must not benulluri- the Redis URI, must not benull- Returns:
- a new instance of
RedisModulesClient
-
create
public static RedisModulesClient create(io.lettuce.core.resource.ClientResources clientResources, io.lettuce.core.RedisURI redisURI) Create a new client that connects to the supplieduriwith sharedClientResources. You need to shut down theClientResourcesupon shutting down your application.You can connect to different Redis servers but you must supply aRedisURIon connecting.- Parameters:
clientResources- the client resources, must not benullredisURI- the Redis URI, must not benull- Returns:
- a new instance of
RedisModulesClient
-
builder
-
uriBuilder
-
connect
Open a new connection to a Redis server that treats keys and values as UTF-8 strings.- Overrides:
connectin classio.lettuce.core.RedisClient- Returns:
- A new stateful Redis connection
-
connect
public <K,V> StatefulRedisModulesConnection<K,V> connect(io.lettuce.core.codec.RedisCodec<K, V> codec) Open a new connection to a Redis server. Use the suppliedcodecto encode/decode keys and values.- Overrides:
connectin classio.lettuce.core.RedisClient- Type Parameters:
K- Key typeV- Value type- Parameters:
codec- Use this codec to encode/decode keys and values, must not benull- Returns:
- A new stateful Redis connection
-
connect
Open a new connection to a Redis server using the suppliedRedisURIthat treats keys and values as UTF-8 strings.- Overrides:
connectin classio.lettuce.core.RedisClient- Parameters:
redisURI- the Redis server to connect to, must not benull- Returns:
- A new connection
-
connect
public <K,V> StatefulRedisModulesConnection<K,V> connect(io.lettuce.core.codec.RedisCodec<K, V> codec, io.lettuce.core.RedisURI redisURI) Open a new connection to a Redis server using the suppliedRedisURIand the suppliedcodecto encode/decode keys.- Overrides:
connectin classio.lettuce.core.RedisClient- Type Parameters:
K- Key typeV- Value type- Parameters:
codec- Use this codec to encode/decode keys and values, must not benullredisURI- the Redis server to connect to, must not benull- Returns:
- A new connection
-
newStatefulRedisConnection
protected <K,V> StatefulRedisModulesConnectionImpl<K,V> newStatefulRedisConnection(io.lettuce.core.RedisChannelWriter channelWriter, io.lettuce.core.protocol.PushHandler pushHandler, io.lettuce.core.codec.RedisCodec<K, V> codec, Duration timeout) Create a new instance ofStatefulRedisModulesConnectionImplor a subclass.Subclasses of
RedisModulesClientmay override that method.- Overrides:
newStatefulRedisConnectionin classio.lettuce.core.RedisClient- Type Parameters:
K- Key-TypeV- Value Type- Parameters:
channelWriter- the channel writercodec- codectimeout- default timeout- Returns:
- new instance of StatefulRedisModulesConnectionImpl
-