Package glide.api.commands
Interface ConnectionManagementClusterCommands
-
- All Known Implementing Classes:
GlideClusterClient
public interface ConnectionManagementClusterCommandsSupports commands for the "Connection Management" group for a cluster client.- See Also:
- Connection Management Commands
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.util.concurrent.CompletableFuture<java.lang.String>clientGetName()Gets the name of the current connection.
The command will be routed a random node.java.util.concurrent.CompletableFuture<ClusterValue<java.lang.String>>clientGetName(RequestRoutingConfiguration.Route route)Gets the name of the current connection.java.util.concurrent.CompletableFuture<java.lang.Long>clientId()Gets the current connection id.
The command will be routed to a random node.java.util.concurrent.CompletableFuture<ClusterValue<java.lang.Long>>clientId(RequestRoutingConfiguration.Route route)Gets the current connection id.java.util.concurrent.CompletableFuture<java.lang.String>clientPause(long timeout)Suspends all clients for the specified timeout.
The command will be routed to all primary nodes.java.util.concurrent.CompletableFuture<java.lang.String>clientPause(long timeout, ClientPauseMode mode)Suspends all clients for the specified timeout.
The command will be routed to all primary nodes.java.util.concurrent.CompletableFuture<java.lang.String>clientPause(long timeout, ClientPauseMode mode, RequestRoutingConfiguration.Route route)Suspends all clients for the specified timeout.
The command will be routed to the nodes defined byroute.java.util.concurrent.CompletableFuture<java.lang.String>clientPause(long timeout, RequestRoutingConfiguration.Route route)Suspends all clients for the specified timeout.
The command will be routed to the nodes defined byroute.java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,java.lang.Object>>clientTrackingInfo()Returns information about the current client connection's use of the server assisted client side caching feature.java.util.concurrent.CompletableFuture<ClusterValue<java.util.Map<java.lang.String,java.lang.Object>>>clientTrackingInfo(RequestRoutingConfiguration.Route route)Returns information about the current client connection's use of the server assisted client side caching feature.java.util.concurrent.CompletableFuture<java.lang.String>clientUnpause()Resumes processing commands on all clients.
The command will be routed to all primary nodes.java.util.concurrent.CompletableFuture<java.lang.String>clientUnpause(RequestRoutingConfiguration.Route route)Resumes processing commands on all clients.
The command will be routed to the nodes defined byroute.java.util.concurrent.CompletableFuture<GlideString>echo(GlideString message)Echoes the providedmessageback.
The command will be routed a random node.java.util.concurrent.CompletableFuture<ClusterValue<GlideString>>echo(GlideString message, RequestRoutingConfiguration.Route route)Echoes the providedmessageback.java.util.concurrent.CompletableFuture<java.lang.String>echo(java.lang.String message)Echoes the providedmessageback.
The command will be routed a random node.java.util.concurrent.CompletableFuture<ClusterValue<java.lang.String>>echo(java.lang.String message, RequestRoutingConfiguration.Route route)Echoes the providedmessageback.java.util.concurrent.CompletableFuture<java.lang.String>ping()Pings the server.
The command will be routed to all primary nodes.java.util.concurrent.CompletableFuture<java.lang.String>ping(RequestRoutingConfiguration.Route route)Pings the server.java.util.concurrent.CompletableFuture<GlideString>ping(GlideString message)Pings the server.
The command will be routed to all primary nodes.java.util.concurrent.CompletableFuture<GlideString>ping(GlideString message, RequestRoutingConfiguration.Route route)Pings the server.java.util.concurrent.CompletableFuture<java.lang.String>ping(java.lang.String message)Pings the server.
The command will be routed to all primary nodes.java.util.concurrent.CompletableFuture<java.lang.String>ping(java.lang.String message, RequestRoutingConfiguration.Route route)Pings the server.java.util.concurrent.CompletableFuture<java.lang.String>reset()Resets the connection state.java.util.concurrent.CompletableFuture<java.lang.String>select(long index)Changes the currently selected database.
-
-
-
Method Detail
-
ping
java.util.concurrent.CompletableFuture<java.lang.String> ping()
Pings the server.
The command will be routed to all primary nodes.- Returns:
Stringwith"PONG".- See Also:
- valkey.io for details.
- Example:
String payload = clusterClient.ping().get(); assert payload.equals("PONG");
-
ping
java.util.concurrent.CompletableFuture<java.lang.String> ping(java.lang.String message)
Pings the server.
The command will be routed to all primary nodes.- Parameters:
message- The server will respond with a copy of the message.- Returns:
Stringwith a copy of the argumentmessage.- See Also:
- valkey.io for details.
- Example:
String payload = clusterClient.ping("GLIDE").get(); assert payload.equals("GLIDE");
-
ping
java.util.concurrent.CompletableFuture<GlideString> ping(GlideString message)
Pings the server.
The command will be routed to all primary nodes.- Parameters:
message- The server will respond with a copy of the message.- Returns:
GlideStringwith a copy of the argumentmessage.- See Also:
- valkey.io for details.
- Example:
GlideString payload = clusterClient.ping(gs("GLIDE")).get(); assert payload.equals(gs("GLIDE"));
-
ping
java.util.concurrent.CompletableFuture<java.lang.String> ping(RequestRoutingConfiguration.Route route)
Pings the server.- Parameters:
route- Specifies the routing configuration for the command. The client will route the command to the nodes defined byroute.- Returns:
Stringwith"PONG".- See Also:
- valkey.io for details.
- Example:
String payload = clusterClient.ping(ALL_NODES).get(); assert payload.equals("PONG");
-
ping
java.util.concurrent.CompletableFuture<java.lang.String> ping(java.lang.String message, RequestRoutingConfiguration.Route route)Pings the server.- Parameters:
message- The ping argument that will be returned.route- Specifies the routing configuration for the command. The client will route the command to the nodes defined byroute.- Returns:
Stringwith a copy of the argumentmessage.- See Also:
- valkey.io for details.
- Example:
String payload = clusterClient.ping("GLIDE", RANDOM).get(); assert payload.equals("GLIDE");
-
ping
java.util.concurrent.CompletableFuture<GlideString> ping(GlideString message, RequestRoutingConfiguration.Route route)
Pings the server.- Parameters:
message- The ping argument that will be returned.route- Specifies the routing configuration for the command. The client will route the command to the nodes defined byroute.- Returns:
GlideStringwith a copy of the argumentmessage.- See Also:
- valkey.io for details.
- Example:
GlideString payload = clusterClient.ping(gs("GLIDE"), RANDOM).get(); assert payload.equals(gs("GLIDE"));
-
clientId
java.util.concurrent.CompletableFuture<java.lang.Long> clientId()
Gets the current connection id.
The command will be routed to a random node.- Returns:
- The id of the client.
- See Also:
- valkey.io for details.
- Example:
long id = client.clientId().get(); assert id > 0
-
clientId
java.util.concurrent.CompletableFuture<ClusterValue<java.lang.Long>> clientId(RequestRoutingConfiguration.Route route)
Gets the current connection id.- Parameters:
route- Specifies the routing configuration for the command. The client will route the command to the nodes defined byroute.- Returns:
- A
ClusterValuewhich holds a single value if single node route is used or a dictionary where each address is the key and its corresponding node response is the value. The value is the id of the client on that node. - See Also:
- valkey.io for details.
- Example:
{@code long id = client.clientId(new SlotIdRoute(...)).get().getSingleValue(); assert id > 0; MapidPerNode = client.clientId(ALL_NODES).get().getMultiValue(); assert idPerNode.get("node1.example.com:6379") > 0;
-
clientGetName
java.util.concurrent.CompletableFuture<java.lang.String> clientGetName()
Gets the name of the current connection.
The command will be routed a random node.- Returns:
- The name of the client connection as a string if a name is set, or
nullif no name is assigned. - See Also:
- valkey.io for details.
- Example:
String clientName = client.clientGetName().get(); assert clientName != null;
-
clientGetName
java.util.concurrent.CompletableFuture<ClusterValue<java.lang.String>> clientGetName(RequestRoutingConfiguration.Route route)
Gets the name of the current connection.- Parameters:
route- Specifies the routing configuration for the command. The client will route the command to the nodes defined byroute.- Returns:
- A
ClusterValuewhich holds a single value if single node route is used or a dictionary where each address is the key and its corresponding node response is the value. The value is the name of the client connection as a string if a name is set, or null if no name is assigned. - See Also:
- valkey.io for details.
- Example:
String clientName = client.clientGetName(new SlotIdRoute(...)).get().getSingleValue(); assert clientName != null; Map<String, String> clientNamePerNode = client.clientGetName(ALL_NODES).get().getMultiValue(); assert clientNamePerNode.get("node1.example.com:6379") != null;
-
echo
java.util.concurrent.CompletableFuture<java.lang.String> echo(java.lang.String message)
Echoes the providedmessageback.
The command will be routed a random node.- Parameters:
message- The message to be echoed back.- Returns:
- The provided
message. - See Also:
- valkey.io for details.
- Example:
String payload = client.echo("GLIDE").get(); assert payload.equals("GLIDE");
-
echo
java.util.concurrent.CompletableFuture<GlideString> echo(GlideString message)
Echoes the providedmessageback.
The command will be routed a random node.- Parameters:
message- The message to be echoed back.- Returns:
- The provided
message. - See Also:
- valkey.io for details.
- Example:
GlideString payload = client.echo(gs("GLIDE")).get(); assert payload.equals(gs("GLIDE"));
-
echo
java.util.concurrent.CompletableFuture<ClusterValue<java.lang.String>> echo(java.lang.String message, RequestRoutingConfiguration.Route route)
Echoes the providedmessageback.- Parameters:
message- The message to be echoed back.route- Specifies the routing configuration for the command. The client will route the command to the nodes defined byroute.- Returns:
- The provided
message. - See Also:
- valkey.io for details.
- Example:
// Command sent to a single random node via RANDOM route, expecting a SingleValue result. String message = client.echo("GLIDE", RANDOM).get().getSingleValue(); assert message.equals("GLIDE"); // Command sent to all nodes via ALL_NODES route, expecting a MultiValue result. Map<String, String> msgForAllNodes = client.echo("GLIDE", ALL_NODES).get().getMultiValue(); for(var msgPerNode : msgForAllNodes.entrySet()) { assert msgPerNode.equals("GLIDE"); }
-
echo
java.util.concurrent.CompletableFuture<ClusterValue<GlideString>> echo(GlideString message, RequestRoutingConfiguration.Route route)
Echoes the providedmessageback.- Parameters:
message- The message to be echoed back.route- Specifies the routing configuration for the command. The client will route the command to the nodes defined byroute.- Returns:
- The provided
message. - See Also:
- valkey.io for details.
- Example:
// Command sent to a single random node via RANDOM route, expecting a SingleValue result. GlideString message = client.echo(gs("GLIDE"), RANDOM).get().getSingleValue(); assert message.equals(gs("GLIDE")); // Command sent to all nodes via ALL_NODES route, expecting a MultiValue result. Map<String, GlideString> msgForAllNodes = client.echo(gs("GLIDE"), ALL_NODES).get().getMultiValue(); for(var msgPerNode : msgForAllNodes.entrySet()) { assert msgPerNode.equals(gs("GLIDE")); }
-
select
java.util.concurrent.CompletableFuture<java.lang.String> select(long index)
Changes the currently selected database.- Parameters:
index- The index of the database to select.- Returns:
- A simple
OKresponse. - See Also:
- valkey.io for details.
- Example:
String response = regularClient.select(0).get(); assert response.equals("OK");
-
clientPause
java.util.concurrent.CompletableFuture<java.lang.String> clientPause(long timeout)
Suspends all clients for the specified timeout.
The command will be routed to all primary nodes.- Parameters:
timeout- The time in milliseconds to pause clients.- Returns:
OK.- See Also:
- valkey.io for details.
- Example:
String response = clusterClient.clientPause(1000).get(); assert response.equals("OK");
-
clientPause
java.util.concurrent.CompletableFuture<java.lang.String> clientPause(long timeout, ClientPauseMode mode)Suspends all clients for the specified timeout.
The command will be routed to all primary nodes.- Parameters:
timeout- The time in milliseconds to pause clients.mode- The pause mode to use.- Returns:
OK.- See Also:
- valkey.io for details.
- Example:
String response = clusterClient.clientPause(1000, ClientPauseMode.WRITE).get(); assert response.equals("OK");
-
clientPause
java.util.concurrent.CompletableFuture<java.lang.String> clientPause(long timeout, RequestRoutingConfiguration.Route route)Suspends all clients for the specified timeout.
The command will be routed to the nodes defined byroute.- Parameters:
timeout- The time in milliseconds to pause clients.route- Specifies the routing configuration for the command. The client will route the command to the nodes defined byroute.- Returns:
OK.- See Also:
- valkey.io for details.
- Example:
String response = clusterClient.clientPause(1000, ALL_PRIMARIES).get(); assert response.equals("OK");
-
clientPause
java.util.concurrent.CompletableFuture<java.lang.String> clientPause(long timeout, ClientPauseMode mode, RequestRoutingConfiguration.Route route)Suspends all clients for the specified timeout.
The command will be routed to the nodes defined byroute.- Parameters:
timeout- The time in milliseconds to pause clients.mode- The pause mode to use.route- Specifies the routing configuration for the command. The client will route the command to the nodes defined byroute.- Returns:
OK.- See Also:
- valkey.io for details.
- Example:
String response = clusterClient.clientPause(1000, ClientPauseMode.WRITE, ALL_PRIMARIES).get(); assert response.equals("OK");
-
clientUnpause
java.util.concurrent.CompletableFuture<java.lang.String> clientUnpause()
Resumes processing commands on all clients.
The command will be routed to all primary nodes.- Returns:
OK.- See Also:
- valkey.io for details.
- Example:
String response = clusterClient.clientUnpause().get(); assert response.equals("OK");
-
clientUnpause
java.util.concurrent.CompletableFuture<java.lang.String> clientUnpause(RequestRoutingConfiguration.Route route)
Resumes processing commands on all clients.
The command will be routed to the nodes defined byroute.- Parameters:
route- Specifies the routing configuration for the command. The client will route the command to the nodes defined byroute.- Returns:
OK.- See Also:
- valkey.io for details.
- Example:
String response = clusterClient.clientUnpause(ALL_PRIMARIES).get(); assert response.equals("OK");
-
reset
java.util.concurrent.CompletableFuture<java.lang.String> reset()
Resets the connection state.- Returns:
Stringwith"RESET".- See Also:
- valkey.io for details.
- Example:
String payload = client.reset().get(); assert payload.equals("RESET");
-
clientTrackingInfo
java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,java.lang.Object>> clientTrackingInfo()
Returns information about the current client connection's use of the server assisted client side caching feature.Routes to a random node by default. To specify routing, use
clientTrackingInfo(Route).- Returns:
- A
Mapwith the client's tracking state. The map contains:flags: aSetof tracking flags. See valkey.io for the full list.redirect: aLongwith the client ID receiving invalidation messages, or-1if not redirectingprefixes: anObject[]of key prefixes monitored for invalidation
- See Also:
- valkey.io for details.
- Example:
// Tracking off (default): Map<String, Object> info = client.clientTrackingInfo().get(); Set<String> flags = (Set<String>) info.get("flags"); // e.g. {"off"} Long redirect = (Long) info.get("redirect"); // e.g. -1L Object[] prefixes = (Object[]) info.get("prefixes"); // e.g. [] // Tracking on with prefix: // {"flags": {"on", "noloop"}, "redirect": -1L, "prefixes": ["key:"]} for (Object prefix : (Object[]) info.get("prefixes")) { System.out.println((String) prefix); }
-
clientTrackingInfo
java.util.concurrent.CompletableFuture<ClusterValue<java.util.Map<java.lang.String,java.lang.Object>>> clientTrackingInfo(RequestRoutingConfiguration.Route route)
Returns information about the current client connection's use of the server assisted client side caching feature.- Parameters:
route- Specifies the routing configuration for the command.- Returns:
- A
ClusterValuecontaining the tracking state map per the routing.- For a
RequestRoutingConfiguration.SingleNodeRoute: a singleMapwhere:flags: aSetof tracking flags. See valkey.io for the full list.redirect: aLongwith the client ID receiving invalidation messages, or-1if not redirectingprefixes: anObject[]of key prefixes monitored for invalidation
- For a multi-node route: a
Mapof node address to tracking state map.
- For a
- See Also:
- valkey.io for details.
- Example:
// Single node: Map<String, Object> info = client.clientTrackingInfo(RANDOM).get().getSingleValue(); Set<String> flags = (Set<String>) info.get("flags"); // e.g. {"off"} Long redirect = (Long) info.get("redirect"); // e.g. -1 Object[] prefixes = (Object[]) info.get("prefixes"); // e.g. [] for (Object prefix : (Object[]) info.get("prefixes")) { System.out.println((String) prefix); } // Multi-node: Map<String, Map<String, Object>> allNodes = client.clientTrackingInfo(ALL_NODES).get().getMultiValue();
-
-