- 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 Summary
Modifier and Type Method Description voidclose()CompletableFuture<Void>closeAsync()Asynchronously close theRedisChannelWriter.voidflushCommands()Flush pending commands.ClientResourcesgetClientResources()voidreset()Deprecated.since 5.2.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,?>> commands)Write multiple commands on the channel.
-
Method Details
-
write
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 typeV- value type- Parameters:
commands- the Redis commands.- Returns:
- the written redis command
-
close
void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
closeAsync
CompletableFuture<Void> closeAsync()Asynchronously close theRedisChannelWriter.- Specified by:
closeAsyncin interfaceAsyncCloseable- Returns:
- future for result synchronization.
- Since:
- 5.1
-
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
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 istrue. If autoFlushCommands is disabled, multiple commands can be issued without writing them actually to the transport. Commands are buffered until aflushCommands()is issued. After callingflushCommands()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
-