Interface StatefulConnection<K,​V>

    • Method Detail

      • addListener

        void addListener​(RedisConnectionStateListener listener)
        Add a listener for the RedisConnectionStateListener. The listener is notified every time a connect/disconnect/IO exception happens. The listener is called on the event loop thread so code within the listener methods must not block.
        Parameters:
        listener - must not be null.
        Since:
        6.2
      • removeListener

        void removeListener​(RedisConnectionStateListener listener)
        Removes a listener.
        Parameters:
        listener - must not be null.
        Since:
        6.2
      • setTimeout

        void setTimeout​(Duration timeout)
        Set the default command timeout for this connection. A zero timeout value indicates to not time out.
        Parameters:
        timeout - Command timeout.
        Since:
        5.0
      • getTimeout

        Duration getTimeout()
        Returns:
        the timeout.
      • dispatch

        <T> RedisCommand<K,​V,​T> dispatch​(RedisCommand<K,​V,​T> command)
        Dispatch a command. Write a command on the channel. The command may be changed/wrapped during write and the written instance is returned after the call. This command does not wait until the command completes and does not guarantee whether the command is executed successfully.
        Type Parameters:
        T - result type
        Parameters:
        command - the Redis command.
        Returns:
        the written Redis command.
      • dispatch

        Collection<RedisCommand<K,​V,​?>> dispatch​(Collection<? extends RedisCommand<K,​V,​?>> commands)
        Dispatch multiple command in a single write on the channel. The commands may be changed/wrapped during write and the written instance is returned after the call. This command does not wait until the command completes and does not guarantee whether the command is executed successfully.
        Parameters:
        commands - the Redis commands.
        Returns:
        the written Redis commands.
        Since:
        5.0
      • close

        void close()
        Close the connection. The connection will become not usable anymore as soon as this method was called.
        Specified by:
        close in interface AutoCloseable
      • isOpen

        boolean isOpen()
        Returns:
        true if the connection is open (connected and not closed).
      • getOptions

        ClientOptions getOptions()
        Returns:
        the client options valid for this connection.
      • getResources

        ClientResources getResources()
        Returns:
        the client resources used for this connection.
      • reset

        @Deprecated
        void reset()
        Deprecated.
        since 5.2. To be removed with 7.0. This method is unsafe and can cause protocol offsets (i.e. Redis commands are completed with previous command values).
        Reset the command state. Queued commands will be canceled and the internal state will be reset. This is useful when the internal state machine gets out of sync with the connection (e.g. errors during external SSL tunneling). Calling this method will reset the protocol state, therefore it is considered unsafe.
      • setAutoFlushCommands

        void setAutoFlushCommands​(boolean autoFlush)
        Disable or enable auto-flush behavior. Default is true. If autoFlushCommands is disabled, multiple commands can be issued without writing them actually to the transport. Commands are buffered until a flushCommands() is issued. After calling flushCommands() commands are sent to the transport and executed by Redis.
        Parameters:
        autoFlush - state of autoFlush.
      • flushCommands

        void flushCommands()
        Flush pending commands. This commands forces a flush on the channel and can be used to buffer ("pipeline") commands to achieve batching. No-op if channel is not connected.