Class RediSearchClient


  • public class RediSearchClient
    extends io.lettuce.core.RedisClient
    A 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.

    RediSearchClient can be used with:

    • Redis Standalone

    RediSearchClient 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.

    See Also:
    RedisURI, StatefulRediSearchConnection, RedisFuture, Mono, Flux, RedisCodec, ClientOptions, ClientResources, MasterReplica
    • Field Summary

      • Fields inherited from class io.lettuce.core.AbstractRedisClient

        channels, closeableResources, connectionEvents
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected RediSearchClient()
      Creates a uri-less RediSearchClient.
      protected RediSearchClient​(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 supplied RedisURI and the supplied codec to 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 supplied RedisURI that treats keys and values as UTF-8 strings.
      static RediSearchClient create()
      Creates a uri-less RediSearchClient with default ClientResources.
      static RediSearchClient create​(io.lettuce.core.RedisURI redisURI)
      Create a new client that connects to the supplied uri with default ClientResources.
      static RediSearchClient create​(io.lettuce.core.resource.ClientResources clientResources)
      Creates a uri-less RediSearchClient with shared ClientResources.
      static RediSearchClient create​(io.lettuce.core.resource.ClientResources clientResources, io.lettuce.core.RedisURI redisURI)
      Create a new client that connects to the supplied uri with shared ClientResources.
      static RediSearchClient create​(io.lettuce.core.resource.ClientResources clientResources, java.lang.String uri)
      Create a new client that connects to the supplied uri with shared ClientResources.You need to shut down the ClientResources upon shutting down your application.
      static RediSearchClient create​(java.lang.String uri)
      Create a new client that connects to the supplied uri with default ClientResources.
      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 of StatefulRediSearchConnectionImpl or 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
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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 a RedisURI on connecting. Methods without having a RedisURI will fail with a IllegalStateException. Non-private constructor to make RediSearchClient proxyable.
    • Method Detail

      • create

        public static RediSearchClient create()
        Creates a uri-less RediSearchClient with default ClientResources. You can connect to different Redis servers but you must supply a RedisURI on connecting. Methods without having a RedisURI will fail with a IllegalStateException.
        Returns:
        a new instance of RediSearchClient
      • create

        public static RediSearchClient create​(io.lettuce.core.RedisURI redisURI)
        Create a new client that connects to the supplied uri with default ClientResources. You can connect to different Redis servers but you must supply a RedisURI on connecting.
        Parameters:
        redisURI - the Redis URI, must not be null
        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 default ClientResources. You can connect to different Redis servers but you must supply a RedisURI on connecting.
        Parameters:
        uri - the Redis URI, must not be null
        Returns:
        a new instance of RediSearchClient
      • create

        public static RediSearchClient create​(io.lettuce.core.resource.ClientResources clientResources)
        Creates a uri-less RediSearchClient with shared ClientResources. You need to shut down the ClientResources upon shutting down your application. You can connect to different Redis servers but you must supply a RedisURI on connecting. Methods without having a RedisURI will fail with a IllegalStateException.
        Parameters:
        clientResources - the client resources, must not be null
        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 shared ClientResources.You need to shut down the ClientResources upon shutting down your application. You can connect to different Redis servers but you must supply a RedisURI on connecting.
        Parameters:
        clientResources - the client resources, must not be null
        uri - the Redis URI, must not be null
        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 supplied uri with shared ClientResources. You need to shut down the ClientResources upon shutting down your application.You can connect to different Redis servers but you must supply a RedisURI on connecting.
        Parameters:
        clientResources - the client resources, must not be null
        redisURI - the Redis URI, must not be null
        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:
        connect in class io.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 supplied codec to encode/decode keys and values.
        Overrides:
        connect in class io.lettuce.core.RedisClient
        Type Parameters:
        K - Key type
        V - Value type
        Parameters:
        codec - Use this codec to encode/decode keys and values, must not be null
        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 supplied RedisURI that treats keys and values as UTF-8 strings.
        Overrides:
        connect in class io.lettuce.core.RedisClient
        Parameters:
        redisURI - the Redis server to connect to, must not be null
        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 supplied RedisURI and the supplied codec to encode/decode keys.
        Overrides:
        connect in class io.lettuce.core.RedisClient
        Type Parameters:
        K - Key type
        V - Value type
        Parameters:
        codec - Use this codec to encode/decode keys and values, must not be null
        redisURI - the Redis server to connect to, must not be null
        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 of StatefulRediSearchConnectionImpl or a subclass.

        Subclasses of RediSearchClient may override that method.

        Overrides:
        newStatefulRedisConnection in class io.lettuce.core.RedisClient
        Type Parameters:
        K - Key-Type
        V - Value Type
        Parameters:
        channelWriter - the channel writer
        codec - codec
        timeout - default timeout
        Returns:
        new instance of StatefulRediSearchConnectionImpl