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 Summary
Constructors Constructor Description RedisChannelHandler(RedisChannelWriter writer, Duration timeout) -
Method Summary
Modifier and Type Method Description voidactivated()Notification when the connection becomes active (connected).protected voidaddListener(io.lettuce.core.CloseEvents.CloseListener listener)voidclose()Close the connection (synchronous).CompletableFuture<Void>closeAsync()Close the connection (asynchronous).voiddeactivated()Notification when the connection becomes inactive (disconnected).protected <T> RedisCommand<K,V,T>dispatch(RedisCommand<K,V,T> cmd)protected Collection<RedisCommand<K,V,?>>dispatch(Collection<? extends RedisCommand<K,V,?>> commands)voidflushCommands()RedisChannelWritergetChannelWriter()ClientOptionsgetOptions()ClientResourcesgetResources()DurationgetTimeout()booleanisClosed()booleanisOpen()voidregisterCloseables(Collection<Closeable> registry, Closeable... closeables)Register Closeable resources.voidreset()Deprecated.voidsetAutoFlushCommands(boolean autoFlush)voidsetOptions(ClientOptions clientOptions)voidsetTimeout(Duration timeout)Set the command timeout for this connection.protected <T> TsyncHandler(Object asyncApi, Class<?>... interfaces)
-
Constructor Details
-
RedisChannelHandler
- Parameters:
writer- the channel writertimeout- timeout value
-
-
Method Details
-
setTimeout
Set the command timeout for this connection.- Parameters:
timeout- Command timeout.- Since:
- 5.0
-
close
public void close()Close the connection (synchronous).- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
closeAsync
Close the connection (asynchronous).- Since:
- 5.1
-
dispatch
-
dispatch
protected Collection<RedisCommand<K,V,?>> dispatch(Collection<? extends RedisCommand<K,V,?>> commands) -
registerCloseables
Register Closeable resources. Internal access only.- Parameters:
registry- registry of closeablescloseables- 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:
activatedin interfaceConnectionFacade
-
deactivated
public void deactivated()Notification when the connection becomes inactive (disconnected).- Specified by:
deactivatedin interfaceConnectionFacade
-
getChannelWriter
- Returns:
- the channel writer
-
isOpen
public boolean isOpen()- Returns:
- true if the connection is active and not closed.
-
reset
Deprecated.Description copied from interface:ConnectionFacadeReset the connection state.- Specified by:
resetin interfaceConnectionFacade
-
getOptions
-
getResources
-
setOptions
-
getTimeout
-
syncHandler
-
setAutoFlushCommands
public void setAutoFlushCommands(boolean autoFlush) -
flushCommands
public void flushCommands()
-