Module lettuce.core

Class RedisChannelHandler<K,​V>

java.lang.Object
io.lettuce.core.RedisChannelHandler<K,​V>
Type Parameters:
K - Key type.
V - Value type.
All Implemented Interfaces:
ConnectionFacade, Closeable, AutoCloseable
Direct Known Subclasses:
StatefulRedisClusterConnectionImpl, StatefulRedisConnectionImpl, StatefulRedisSentinelConnectionImpl

public abstract class RedisChannelHandler<K,​V>
extends Object
implements Closeable, ConnectionFacade
Abstract base for every Redis connection. Provides basic connection functionality and tracks open resources.
Since:
3.0
Author:
Mark Paluch
  • Constructor Details

    • RedisChannelHandler

      public RedisChannelHandler​(RedisChannelWriter writer, Duration timeout)
      Parameters:
      writer - the channel writer
      timeout - timeout value
  • Method Details

    • setTimeout

      public void setTimeout​(Duration timeout)
      Set the command timeout for this connection.
      Parameters:
      timeout - Command timeout.
      Since:
      5.0
    • close

      public void close()
      Close the connection (synchronous).
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
    • closeAsync

      public CompletableFuture<Void> closeAsync()
      Close the connection (asynchronous).
      Since:
      5.1
    • dispatch

      protected <T> RedisCommand<K,​V,​T> dispatch​(RedisCommand<K,​V,​T> cmd)
    • dispatch

      protected Collection<RedisCommand<K,​V,​?>> dispatch​(Collection<? extends RedisCommand<K,​V,​?>> commands)
    • registerCloseables

      public void registerCloseables​(Collection<Closeable> registry, Closeable... closeables)
      Register Closeable resources. Internal access only.
      Parameters:
      registry - registry of closeables
      closeables - closeables to register
    • addListener

      protected void addListener​(io.lettuce.core.CloseEvents.CloseListener listener)
    • isClosed

      public boolean isClosed()
      Returns:
      true if the connection is closed (final state in the connection lifecyle).
    • activated

      public void activated()
      Notification when the connection becomes active (connected).
      Specified by:
      activated in interface ConnectionFacade
    • deactivated

      public void deactivated()
      Notification when the connection becomes inactive (disconnected).
      Specified by:
      deactivated in interface ConnectionFacade
    • getChannelWriter

      public RedisChannelWriter getChannelWriter()
      Returns:
      the channel writer
    • isOpen

      public boolean isOpen()
      Returns:
      true if the connection is active and not closed.
    • reset

      @Deprecated public void reset()
      Deprecated.
      Description copied from interface: ConnectionFacade
      Reset the connection state.
      Specified by:
      reset in interface ConnectionFacade
    • getOptions

      public ClientOptions getOptions()
    • getResources

      public ClientResources getResources()
    • setOptions

      public void setOptions​(ClientOptions clientOptions)
    • getTimeout

      public Duration getTimeout()
    • syncHandler

      protected <T> T syncHandler​(Object asyncApi, Class<?>... interfaces)
    • setAutoFlushCommands

      public void setAutoFlushCommands​(boolean autoFlush)
    • flushCommands

      public void flushCommands()