Module lettuce.core

Class CommandExpiryWriter

java.lang.Object
io.lettuce.core.protocol.CommandExpiryWriter
All Implemented Interfaces:
AsyncCloseable, RedisChannelWriter, Closeable, AutoCloseable

public class CommandExpiryWriter
extends Object
implements RedisChannelWriter
Extension to RedisChannelWriter that expires commands. Command timeout starts at the time the command is written regardless to flushing mode (user-controlled batching).
Since:
5.1
Author:
Mark Paluch
See Also:
TimeoutOptions
  • Constructor Details

  • Method Details

    • isSupported

      public static boolean isSupported​(ClientOptions clientOptions)
      Check whether ClientOptions is configured to timeout commands.
      Parameters:
      clientOptions - must not be null.
      Returns:
      true if ClientOptions are configured to timeout commands.
    • setConnectionFacade

      public void setConnectionFacade​(ConnectionFacade connectionFacade)
      Description copied from interface: RedisChannelWriter
      Set the corresponding connection facade in order to notify it about channel active/inactive state.
      Specified by:
      setConnectionFacade in interface RedisChannelWriter
      Parameters:
      connectionFacade - the connection facade (external connection object)
    • getClientResources

      public ClientResources getClientResources()
      Specified by:
      getClientResources in interface RedisChannelWriter
      Returns:
      the ClientResources.
    • setAutoFlushCommands

      public void setAutoFlushCommands​(boolean autoFlush)
      Description copied from interface: RedisChannelWriter
      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 RedisChannelWriter.flushCommands() is issued. After calling RedisChannelWriter.flushCommands() commands are sent to the transport and executed by Redis.
      Specified by:
      setAutoFlushCommands in interface RedisChannelWriter
      Parameters:
      autoFlush - state of autoFlush.
    • write

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

      public <K,​ V> Collection<RedisCommand<K,​V,​?>> write​(Collection<? extends RedisCommand<K,​V,​?>> redisCommands)
      Description copied from interface: RedisChannelWriter
      Write multiple commands on the channel. The commands may be changed/wrapped during write and the written instance is returned after the call.
      Specified by:
      write in interface RedisChannelWriter
      Type Parameters:
      K - key type
      V - value type
      Parameters:
      redisCommands - the Redis commands.
      Returns:
      the written redis command
    • flushCommands

      public void flushCommands()
      Description copied from interface: RedisChannelWriter
      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.
      Specified by:
      flushCommands in interface RedisChannelWriter
    • close

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

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

      public void reset()
      Description copied from interface: RedisChannelWriter
      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.
      Specified by:
      reset in interface RedisChannelWriter
    • setTimeout

      public void setTimeout​(Duration timeout)