Package io.lettuce.core
Class TrackingArgs
- java.lang.Object
-
- io.lettuce.core.TrackingArgs
-
- All Implemented Interfaces:
CompositeArgument
public class TrackingArgs extends Object implements CompositeArgument
Argument list builder for the Redis CLIENT TRACKING command. Static import the methods fromTrackingArgs.Builder
and chain the method calls:enabled().bcast()
.TrackingArgs
is a mutable object and instances should be used only once to avoid shared mutable state.- Since:
- 6.0
- Author:
- Mark Paluch
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
TrackingArgs.Builder
Builder entry points forTrackingArgs
.
-
Constructor Summary
Constructors Constructor Description TrackingArgs()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TrackingArgs
bcast()
Enable tracking in broadcasting mode.<K,V>
voidbuild(CommandArgs<K,V> args)
Build command arguments and contribute arguments toCommandArgs
.TrackingArgs
enabled(boolean enabled)
Controls whether to enable key tracking for the currently connected client.TrackingArgs
noloop()
Don't send notifications about keys modified by this connection itself.TrackingArgs
optin()
When broadcasting is NOT active, normally don't track keys in read only commands, unless they are called immediately after a CLIENT CACHING yes command.TrackingArgs
optout()
When broadcasting is NOT active, normally track keys in read only commands, unless they are called immediately after a CLIENT CACHING no command.TrackingArgs
prefixes(String... prefixes)
For broadcasting, register a given key prefix, so that notifications will be provided only for keys starting with this string.TrackingArgs
prefixes(Charset charset, String... prefixes)
For broadcasting, register a given key prefix, so that notifications will be provided only for keys starting with this string.TrackingArgs
redirect(long clientId)
Send redirection messages to the connection with the specified ID.
-
-
-
Method Detail
-
enabled
public TrackingArgs enabled(boolean enabled)
Controls whether to enable key tracking for the currently connected client.- Parameters:
enabled
- whether to enable key tracking for the currently connected client.- Returns:
this
TrackingArgs
.
-
redirect
public TrackingArgs redirect(long clientId)
Send redirection messages to the connection with the specified ID. The connection must exist, you can get the ID of such connection usingCLIENT ID
. If the connection we are redirecting to is terminated, when in RESP3 mode the connection with tracking enabled will receive tracking-redir-broken push messages in order to signal the condition.- Parameters:
clientId
- process Id of the client for notification redirection.- Returns:
this
TrackingArgs
.
-
bcast
public TrackingArgs bcast()
Enable tracking in broadcasting mode. In this mode invalidation messages are reported for all the prefixes specified, regardless of the keys requested by the connection. Instead when the broadcasting mode is not enabled, Redis will track which keys are fetched using read-only commands, and will report invalidation messages only for such keys.- Returns:
this
TrackingArgs
.
-
prefixes
public TrackingArgs prefixes(String... prefixes)
For broadcasting, register a given key prefix, so that notifications will be provided only for keys starting with this string. This option can be given multiple times to register multiple prefixes. If broadcasting is enabled without this option, Redis will send notifications for every key.- Parameters:
prefixes
- the key prefixes for broadcasting of change notifications. Encoded usingStandardCharsets.UTF_8
.- Returns:
this
TrackingArgs
.
-
prefixes
public TrackingArgs prefixes(Charset charset, String... prefixes)
For broadcasting, register a given key prefix, so that notifications will be provided only for keys starting with this string. This option can be given multiple times to register multiple prefixes. If broadcasting is enabled without this option, Redis will send notifications for every key.- Parameters:
charset
- the charset to use forprefixes
encoding.prefixes
- the key prefixes for broadcasting of change notifications.- Returns:
this
TrackingArgs
.
-
optin
public TrackingArgs optin()
When broadcasting is NOT active, normally don't track keys in read only commands, unless they are called immediately after a CLIENT CACHING yes command.- Returns:
this
TrackingArgs
.
-
optout
public TrackingArgs optout()
When broadcasting is NOT active, normally track keys in read only commands, unless they are called immediately after a CLIENT CACHING no command.- Returns:
this
TrackingArgs
.
-
noloop
public TrackingArgs noloop()
Don't send notifications about keys modified by this connection itself.- Returns:
this
TrackingArgs
.
-
build
public <K,V> void build(CommandArgs<K,V> args)
Description copied from interface:CompositeArgument
Build command arguments and contribute arguments toCommandArgs
.Implementing classes are required to implement this method. Depending on the command nature and configured arguments, this method may contribute arguments but is not required to add arguments if none are specified.
- Specified by:
build
in interfaceCompositeArgument
- Type Parameters:
K
- Key type.V
- Value type.- Parameters:
args
- the command arguments, must not benull
.
-
-