java.lang.Object
io.lettuce.core.CommandListenerWriter
- All Implemented Interfaces:
AsyncCloseable,RedisChannelWriter,Closeable,AutoCloseable
public class CommandListenerWriter extends Object implements RedisChannelWriter
Writer for command listeners.
- Since:
- 6.1
- Author:
- Mikhael Sokolov, Mark Paluch
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classCommandListenerWriter.CommandListenerMulticasterWraps multiple command listeners into one multicaster. -
Constructor Summary
Constructors Constructor Description CommandListenerWriter(RedisChannelWriter delegate, List<CommandListener> listeners) -
Method Summary
Modifier and Type Method Description voidclose()CompletableFuture<Void>closeAsync()Asynchronously close theRedisChannelWriter.voidflushCommands()Flush pending commands.ClientResourcesgetClientResources()RedisChannelWritergetDelegate()static booleanisSupported(List<CommandListener> commandListeners)Check whether the list ofCommandListeneris not empty.voidreset()Reset the command state.voidsetAutoFlushCommands(boolean autoFlush)Disable or enable auto-flush behavior.voidsetConnectionFacade(ConnectionFacade connection)Set the corresponding connection facade in order to notify it about channel active/inactive state.<K, V, T> RedisCommand<K,V,T>write(RedisCommand<K,V,T> command)Write a command on the channel.<K, V> Collection<RedisCommand<K,V,?>>write(Collection<? extends RedisCommand<K,V,?>> redisCommands)Write multiple commands on the channel.
-
Constructor Details
-
CommandListenerWriter
-
-
Method Details
-
isSupported
Check whether the list ofCommandListeneris not empty.- Parameters:
commandListeners- must not benull.- Returns:
trueif the list ofCommandListeneris not empty.
-
write
Description copied from interface:RedisChannelWriterWrite a command on the channel. The command may be changed/wrapped during write and the written instance is returned after the call.- Specified by:
writein interfaceRedisChannelWriterT- 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:RedisChannelWriterWrite multiple commands on the channel. The commands may be changed/wrapped during write and the written instance is returned after the call.- Specified by:
writein interfaceRedisChannelWriter- Type Parameters:
K- key typeV- value type- Parameters:
redisCommands- the Redis commands.- Returns:
- the written redis command
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceRedisChannelWriter
-
closeAsync
Description copied from interface:RedisChannelWriterAsynchronously close theRedisChannelWriter.- Specified by:
closeAsyncin interfaceAsyncCloseable- Specified by:
closeAsyncin interfaceRedisChannelWriter- Returns:
- future for result synchronization.
-
reset
public void reset()Description copied from interface:RedisChannelWriterReset 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:
resetin interfaceRedisChannelWriter
-
setConnectionFacade
Description copied from interface:RedisChannelWriterSet the corresponding connection facade in order to notify it about channel active/inactive state.- Specified by:
setConnectionFacadein interfaceRedisChannelWriter- Parameters:
connection- the connection facade (external connection object)
-
setAutoFlushCommands
public void setAutoFlushCommands(boolean autoFlush)Description copied from interface:RedisChannelWriterDisable or enable auto-flush behavior. Default istrue. If autoFlushCommands is disabled, multiple commands can be issued without writing them actually to the transport. Commands are buffered until aRedisChannelWriter.flushCommands()is issued. After callingRedisChannelWriter.flushCommands()commands are sent to the transport and executed by Redis.- Specified by:
setAutoFlushCommandsin interfaceRedisChannelWriter- Parameters:
autoFlush- state of autoFlush.
-
flushCommands
public void flushCommands()Description copied from interface:RedisChannelWriterFlush 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:
flushCommandsin interfaceRedisChannelWriter
-
getClientResources
- Specified by:
getClientResourcesin interfaceRedisChannelWriter- Returns:
- the
ClientResources.
-
getDelegate
-