Package com.redis.lettucemod
Class RedisModulesClient
- java.lang.Object
-
- io.lettuce.core.AbstractRedisClient
-
- io.lettuce.core.RedisClient
-
- com.redis.lettucemod.RedisModulesClient
-
- All Implemented Interfaces:
java.lang.AutoCloseable
public class RedisModulesClient extends io.lettuce.core.RedisClientA 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.RedisModulesClientcan be used with:- Redis Standalone
RedisModulesClientis an expensive resource. It holds a set of netty'sEventLoopGroup's that use multiple threads. Reuse this instance as much as possible or share aClientResourcesinstance amongst multiple client instances.- Author:
- Julien Ruaux
- See Also:
RedisURI,StatefulRedisModulesConnection,RedisFuture,Mono,Flux,RedisCodec,ClientOptions,ClientResources,MasterReplica
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedRedisModulesClient()Creates a uri-less RedisModulesClient.protectedRedisModulesClient(io.lettuce.core.resource.ClientResources clientResources, io.lettuce.core.RedisURI redisURI)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static RedisModulesClientBuilderbuilder(io.lettuce.core.RedisURI redisURI)StatefulRedisModulesConnection<java.lang.String,java.lang.String>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.StatefulRedisModulesConnection<java.lang.String,java.lang.String>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(io.lettuce.core.resource.ClientResources clientResources, java.lang.String uri)Create a new client that connects to the supplied uri with sharedClientResources.You need to shut down theClientResourcesupon shutting down your application.static RedisModulesClientcreate(java.lang.String uri)Create a new client that connects to the supplied uri with defaultClientResources.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, java.time.Duration timeout)Create a new instance ofStatefulRedisModulesConnectionImplor a subclass.-
Methods inherited from class io.lettuce.core.RedisClient
connectAsync, connectPubSub, connectPubSub, connectPubSub, connectPubSub, connectPubSubAsync, connectSentinel, connectSentinel, connectSentinel, connectSentinel, connectSentinelAsync, getSocketAddress, newStatefulRedisPubSubConnection, newStatefulRedisSentinelConnection, newStringStringCodec, setOptions
-
Methods 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
-
-
-
-
Constructor Detail
-
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 Detail
-
builder
public static RedisModulesClientBuilder builder(io.lettuce.core.RedisURI redisURI)
-
create
public static RedisModulesClient 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
public static RedisModulesClient create(io.lettuce.core.RedisURI redisURI)
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
public static RedisModulesClient create(java.lang.String uri)
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
public static RedisModulesClient create(io.lettuce.core.resource.ClientResources clientResources)
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, java.lang.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
-
connect
public StatefulRedisModulesConnection<java.lang.String,java.lang.String> 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
public StatefulRedisModulesConnection<java.lang.String,java.lang.String> 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.- 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, java.time.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
-
-