Package com.redislabs.lettusearch
Class RediSearchClient
- java.lang.Object
-
- io.lettuce.core.AbstractRedisClient
-
- io.lettuce.core.RedisClient
-
- com.redislabs.lettusearch.RediSearchClient
-
public class RediSearchClient extends io.lettuce.core.RedisClientA scalable and thread-safe RediSearch client 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.RediSearchClientcan be used with:- Redis Standalone
RediSearchClientis 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.- See Also:
RedisURI,StatefulRediSearchConnection,RedisFuture,Mono,Flux,RedisCodec,ClientOptions,ClientResources,MasterReplica
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedRediSearchClient()Creates a uri-less RediSearchClient.protectedRediSearchClient(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 StatefulRediSearchConnection<java.lang.String,java.lang.String>connect()Open a new connection to a RediSearch server that treats keys and values as UTF-8 strings.<K,V>
StatefulRediSearchConnection<K,V>connect(io.lettuce.core.codec.RedisCodec<K,V> codec)Open a new connection to a RediSearch server.<K,V>
StatefulRediSearchConnection<K,V>connect(io.lettuce.core.codec.RedisCodec<K,V> codec, io.lettuce.core.RedisURI redisURI)Open a new connection to a RediSearch server using the suppliedRedisURIand the suppliedcodecto encode/decode keys.StatefulRediSearchConnection<java.lang.String,java.lang.String>connect(io.lettuce.core.RedisURI redisURI)Open a new connection to a RediSearch server using the suppliedRedisURIthat treats keys and values as UTF-8 strings.static RediSearchClientcreate()Creates a uri-less RediSearchClient with defaultClientResources.static RediSearchClientcreate(io.lettuce.core.RedisURI redisURI)Create a new client that connects to the supplieduriwith defaultClientResources.static RediSearchClientcreate(io.lettuce.core.resource.ClientResources clientResources)Creates a uri-less RediSearchClient with sharedClientResources.static RediSearchClientcreate(io.lettuce.core.resource.ClientResources clientResources, io.lettuce.core.RedisURI redisURI)Create a new client that connects to the supplieduriwith sharedClientResources.static RediSearchClientcreate(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 RediSearchClientcreate(java.lang.String uri)Create a new client that connects to the supplied uri with defaultClientResources.protected <K,V>
StatefulRediSearchConnectionImpl<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 ofStatefulRediSearchConnectionImplor 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, connectionBuilder, createHandshake, getChannelCount, getCommandListeners, getConnection, getConnection, getDefaultTimeout, getOptions, getResourceCount, getResources, initializeChannelAsync, removeListener, removeListener, setDefaultTimeout, setDefaultTimeout, shutdown, shutdown, shutdown, shutdownAsync, shutdownAsync
-
-
-
-
Constructor Detail
-
RediSearchClient
protected RediSearchClient(io.lettuce.core.resource.ClientResources clientResources, io.lettuce.core.RedisURI redisURI)
-
RediSearchClient
protected RediSearchClient()
Creates a uri-less RediSearchClient. You can connect to different Redis servers but you must supply aRedisURIon connecting. Methods without having aRedisURIwill fail with aIllegalStateException. Non-private constructor to makeRediSearchClientproxyable.
-
-
Method Detail
-
create
public static RediSearchClient create()
Creates a uri-less RediSearchClient 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
RediSearchClient
-
create
public static RediSearchClient 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
RediSearchClient
-
create
public static RediSearchClient 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
RediSearchClient
-
create
public static RediSearchClient create(io.lettuce.core.resource.ClientResources clientResources)
Creates a uri-less RediSearchClient 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
RediSearchClient
-
create
public static RediSearchClient 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
RediSearchClient
-
create
public static RediSearchClient 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
RediSearchClient
-
connect
public StatefulRediSearchConnection<java.lang.String,java.lang.String> connect()
Open a new connection to a RediSearch 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> StatefulRediSearchConnection<K,V> connect(io.lettuce.core.codec.RedisCodec<K,V> codec)
Open a new connection to a RediSearch 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 StatefulRediSearchConnection<java.lang.String,java.lang.String> connect(io.lettuce.core.RedisURI redisURI)
Open a new connection to a RediSearch 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> StatefulRediSearchConnection<K,V> connect(io.lettuce.core.codec.RedisCodec<K,V> codec, io.lettuce.core.RedisURI redisURI)
Open a new connection to a RediSearch 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> StatefulRediSearchConnectionImpl<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 ofStatefulRediSearchConnectionImplor a subclass.Subclasses of
RediSearchClientmay 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 StatefulRediSearchConnectionImpl
-
-