Package io.lettuce.core
Interface RedisChannelWriter
-
- All Superinterfaces:
AsyncCloseable
,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
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description void
close()
CompletableFuture<Void>
closeAsync()
Asynchronously close theRedisChannelWriter
.void
flushCommands()
Flush pending commands.ClientResources
getClientResources()
void
reset()
Deprecated.since 5.2.void
setAutoFlushCommands(boolean autoFlush)
Disable or enable auto-flush behavior.void
setConnectionFacade(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 Detail
-
write
<K,V,T> RedisCommand<K,V,T> write(RedisCommand<K,V,T> command)
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:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-
closeAsync
CompletableFuture<Void> closeAsync()
Asynchronously close theRedisChannelWriter
.- Specified by:
closeAsync
in interfaceAsyncCloseable
- Specified by:
closeAsync
in interfaceAsyncCloseable
- Returns:
- future for result synchronization.
- Since:
- 5.1
-
reset
@Deprecated void 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
void setConnectionFacade(ConnectionFacade connection)
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
-
-