Module lettuce.core

Interface RedisChannelWriter

All Superinterfaces:
AsyncCloseable, AutoCloseable, Closeable
All Known Implementing Classes:
CommandExpiryWriter, CommandListenerWriter, DefaultEndpoint, PubSubClusterEndpoint, PubSubEndpoint

public interface RedisChannelWriter
extends Closeable, AsyncCloseable
Writer for a channel. Writers push commands on to the communication channel and maintain a state for the commands.
Since:
3.0
Author:
Mark Paluch
  • Method Details

    • write

      <K,​ V,​ T> RedisCommand<K,​V,​T> write​(RedisCommand<K,​V,​T> command)
      Write a command on the channel. The command may be changed/wrapped during write and the written instance is returned after the call.
      Type Parameters:
      T - result type
      Parameters:
      command - the Redis command.
      Returns:
      the written Redis command.
    • write

      <K,​ V> Collection<RedisCommand<K,​V,​?>> write​(Collection<? extends RedisCommand<K,​V,​?>> commands)
      Write multiple commands on the channel. The commands may be changed/wrapped during write and the written instance is returned after the call.
      Type Parameters:
      K - key type
      V - value type
      Parameters:
      commands - the Redis commands.
      Returns:
      the written redis command
    • close

      void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
    • closeAsync

      CompletableFuture<Void> closeAsync()
      Asynchronously close the RedisChannelWriter.
      Specified by:
      closeAsync in interface AsyncCloseable
      Returns:
      future for result synchronization.
      Since:
      5.1
    • reset

      @Deprecated void reset()
      Deprecated.
      since 5.2. 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.
    • setConnectionFacade

      void setConnectionFacade​(ConnectionFacade connection)
      Set the corresponding connection facade in order to notify it about channel active/inactive state.
      Parameters:
      connection - the connection facade (external connection object)
    • 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.
    • getClientResources

      ClientResources getClientResources()
      Returns:
      the ClientResources.
      Since:
      5.1