Package glide.api.commands
Interface ScriptingAndFunctionsClusterCommands
-
- All Known Implementing Classes:
GlideClusterClient
public interface ScriptingAndFunctionsClusterCommandsSupports commands for the "Scripting and Function" group for a cluster client.- See Also:
- Scripting and Function Commands
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.util.concurrent.CompletableFuture<java.lang.Object>fcall(GlideString function)Invokes a previously loaded function.
The command will be routed to a primary random node.
To route to a replica please refer tofcallReadOnly(String).java.util.concurrent.CompletableFuture<ClusterValue<java.lang.Object>>fcall(GlideString function, RequestRoutingConfiguration.Route route)Invokes a previously loaded function.java.util.concurrent.CompletableFuture<java.lang.Object>fcall(GlideString function, GlideString[] arguments)Invokes a previously loaded function.
The command will be routed to a random primary node.
To route to a replica please refer tofcallReadOnly(String, String[]).java.util.concurrent.CompletableFuture<ClusterValue<java.lang.Object>>fcall(GlideString function, GlideString[] arguments, RequestRoutingConfiguration.Route route)Invokes a previously loaded function.java.util.concurrent.CompletableFuture<java.lang.Object>fcall(java.lang.String function)Invokes a previously loaded function.
The command will be routed to a primary random node.
To route to a replica please refer tofcallReadOnly(String).java.util.concurrent.CompletableFuture<ClusterValue<java.lang.Object>>fcall(java.lang.String function, RequestRoutingConfiguration.Route route)Invokes a previously loaded function.java.util.concurrent.CompletableFuture<java.lang.Object>fcall(java.lang.String function, java.lang.String[] arguments)Invokes a previously loaded function.
The command will be routed to a random primary node.
To route to a replica please refer tofcallReadOnly(String, String[]).java.util.concurrent.CompletableFuture<ClusterValue<java.lang.Object>>fcall(java.lang.String function, java.lang.String[] arguments, RequestRoutingConfiguration.Route route)Invokes a previously loaded function.java.util.concurrent.CompletableFuture<java.lang.Object>fcallReadOnly(GlideString function)Invokes a previously loaded read-only function.
The command is routed to a random node depending on the client'sReadFromstrategy.java.util.concurrent.CompletableFuture<ClusterValue<java.lang.Object>>fcallReadOnly(GlideString function, RequestRoutingConfiguration.Route route)Invokes a previously loaded read-only function.java.util.concurrent.CompletableFuture<java.lang.Object>fcallReadOnly(GlideString function, GlideString[] arguments)Invokes a previously loaded function.
The command is routed to a random node depending on the client'sReadFromstrategy.java.util.concurrent.CompletableFuture<ClusterValue<java.lang.Object>>fcallReadOnly(GlideString function, GlideString[] arguments, RequestRoutingConfiguration.Route route)Invokes a previously loaded read-only function.java.util.concurrent.CompletableFuture<java.lang.Object>fcallReadOnly(java.lang.String function)Invokes a previously loaded read-only function.
The command is routed to a random node depending on the client'sReadFromstrategy.java.util.concurrent.CompletableFuture<ClusterValue<java.lang.Object>>fcallReadOnly(java.lang.String function, RequestRoutingConfiguration.Route route)Invokes a previously loaded read-only function.java.util.concurrent.CompletableFuture<java.lang.Object>fcallReadOnly(java.lang.String function, java.lang.String[] arguments)Invokes a previously loaded function.
The command is routed to a random node depending on the client'sReadFromstrategy.java.util.concurrent.CompletableFuture<ClusterValue<java.lang.Object>>fcallReadOnly(java.lang.String function, java.lang.String[] arguments, RequestRoutingConfiguration.Route route)Invokes a previously loaded read-only function.java.util.concurrent.CompletableFuture<java.lang.String>functionDelete(GlideString libName)Deletes a library and all its functions.
The command will be routed to all primary nodes.java.util.concurrent.CompletableFuture<java.lang.String>functionDelete(GlideString libName, RequestRoutingConfiguration.Route route)Deletes a library and all its functions.java.util.concurrent.CompletableFuture<java.lang.String>functionDelete(java.lang.String libName)Deletes a library and all its functions.
The command will be routed to all primary nodes.java.util.concurrent.CompletableFuture<java.lang.String>functionDelete(java.lang.String libName, RequestRoutingConfiguration.Route route)Deletes a library and all its functions.java.util.concurrent.CompletableFuture<byte[]>functionDump()Returns the serialized payload of all loaded libraries.
The command will be routed to a random node.java.util.concurrent.CompletableFuture<ClusterValue<byte[]>>functionDump(RequestRoutingConfiguration.Route route)Returns the serialized payload of all loaded libraries.java.util.concurrent.CompletableFuture<java.lang.String>functionFlush()Deletes all function libraries.
The command will be routed to all primary nodes.java.util.concurrent.CompletableFuture<java.lang.String>functionFlush(FlushMode mode)Deletes all function libraries.
The command will be routed to all primary nodes.java.util.concurrent.CompletableFuture<java.lang.String>functionFlush(FlushMode mode, RequestRoutingConfiguration.Route route)Deletes all function libraries.java.util.concurrent.CompletableFuture<java.lang.String>functionFlush(RequestRoutingConfiguration.Route route)Deletes all function libraries.java.util.concurrent.CompletableFuture<java.lang.String>functionKill()Kills a function that is currently executing.
FUNCTION KILLterminates read-only functions only.
The command will be routed to all nodes.java.util.concurrent.CompletableFuture<java.lang.String>functionKill(RequestRoutingConfiguration.Route route)Kills a function that is currently executing.
FUNCTION KILLterminates read-only functions only.java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,java.lang.Object>[]>functionList(boolean withCode)Returns information about the functions and libraries.
The command will be routed to a random node.java.util.concurrent.CompletableFuture<ClusterValue<java.util.Map<java.lang.String,java.lang.Object>[]>>functionList(boolean withCode, RequestRoutingConfiguration.Route route)Returns information about the functions and libraries.java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,java.lang.Object>[]>functionList(java.lang.String libNamePattern, boolean withCode)Returns information about the functions and libraries.
The command will be routed to a random node.java.util.concurrent.CompletableFuture<ClusterValue<java.util.Map<java.lang.String,java.lang.Object>[]>>functionList(java.lang.String libNamePattern, boolean withCode, RequestRoutingConfiguration.Route route)Returns information about the functions and libraries.java.util.concurrent.CompletableFuture<java.util.Map<GlideString,java.lang.Object>[]>functionListBinary(boolean withCode)Returns information about the functions and libraries.
The command will be routed to a random node.java.util.concurrent.CompletableFuture<ClusterValue<java.util.Map<GlideString,java.lang.Object>[]>>functionListBinary(boolean withCode, RequestRoutingConfiguration.Route route)Returns information about the functions and libraries.java.util.concurrent.CompletableFuture<java.util.Map<GlideString,java.lang.Object>[]>functionListBinary(GlideString libNamePattern, boolean withCode)Returns information about the functions and libraries.
The command will be routed to a random node.java.util.concurrent.CompletableFuture<ClusterValue<java.util.Map<GlideString,java.lang.Object>[]>>functionListBinary(GlideString libNamePattern, boolean withCode, RequestRoutingConfiguration.Route route)Returns information about the functions and libraries.java.util.concurrent.CompletableFuture<GlideString>functionLoad(GlideString libraryCode, boolean replace)Loads a library to Valkey.
The command will be routed to all primary nodes.java.util.concurrent.CompletableFuture<GlideString>functionLoad(GlideString libraryCode, boolean replace, RequestRoutingConfiguration.Route route)Loads a library to Valkey.java.util.concurrent.CompletableFuture<java.lang.String>functionLoad(java.lang.String libraryCode, boolean replace)Loads a library to Valkey.
The command will be routed to all primary nodes.java.util.concurrent.CompletableFuture<java.lang.String>functionLoad(java.lang.String libraryCode, boolean replace, RequestRoutingConfiguration.Route route)Loads a library to Valkey.java.util.concurrent.CompletableFuture<java.lang.String>functionRestore(byte[] payload)Restores libraries from the serialized payload returned byfunctionDump().
The command will be routed to all primary nodes.java.util.concurrent.CompletableFuture<java.lang.String>functionRestore(byte[] payload, FunctionRestorePolicy policy)Restores libraries from the serialized payload returned byfunctionDump().
The command will be routed to all primary nodes.java.util.concurrent.CompletableFuture<java.lang.String>functionRestore(byte[] payload, FunctionRestorePolicy policy, RequestRoutingConfiguration.Route route)Restores libraries from the serialized payload returned byfunctionDump(Route).java.util.concurrent.CompletableFuture<java.lang.String>functionRestore(byte[] payload, RequestRoutingConfiguration.Route route)Restores libraries from the serialized payload returned byfunctionDump(Route).java.util.concurrent.CompletableFuture<ClusterValue<java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.Object>>>>functionStats()Returns information about the function that's currently running and information about the available execution engines.
The command will be routed to all nodes.java.util.concurrent.CompletableFuture<ClusterValue<java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.Object>>>>functionStats(RequestRoutingConfiguration.Route route)Returns information about the function that's currently running and information about the available execution engines.java.util.concurrent.CompletableFuture<ClusterValue<java.util.Map<GlideString,java.util.Map<GlideString,java.lang.Object>>>>functionStatsBinary()Returns information about the function that's currently running and information about the available execution engines.
The command will be routed to all nodes.java.util.concurrent.CompletableFuture<ClusterValue<java.util.Map<GlideString,java.util.Map<GlideString,java.lang.Object>>>>functionStatsBinary(RequestRoutingConfiguration.Route route)Returns information about the function that's currently running and information about the available execution engines.java.util.concurrent.CompletableFuture<java.lang.Object>invokeScript(Script script, ScriptArgOptionsGlideString options, RequestRoutingConfiguration.Route route)Invokes a Lua script with its keys and arguments.
This method simplifies the process of invoking scripts on the server by using an object that represents a Lua script.java.util.concurrent.CompletableFuture<java.lang.Object>invokeScript(Script script, ScriptArgOptions options, RequestRoutingConfiguration.Route route)Invokes a Lua script with its keys and arguments.
This method simplifies the process of invoking scripts on the server by using an object that represents a Lua script.java.util.concurrent.CompletableFuture<java.lang.Object>invokeScript(Script script, RequestRoutingConfiguration.Route route)Invokes a Lua script.
This method simplifies the process of invoking scripts on the server by using an object that represents a Lua script.java.util.concurrent.CompletableFuture<java.lang.Boolean[]>scriptExists(GlideString[] sha1s)Checks existence of scripts in the script cache by their SHA1 digest.
The command will be routed to all primary nodes.java.util.concurrent.CompletableFuture<java.lang.Boolean[]>scriptExists(GlideString[] sha1s, RequestRoutingConfiguration.Route route)Checks existence of scripts in the script cache by their SHA1 digest.java.util.concurrent.CompletableFuture<java.lang.Boolean[]>scriptExists(java.lang.String[] sha1s)Checks existence of scripts in the script cache by their SHA1 digest.
The command will be routed to all primary nodes.java.util.concurrent.CompletableFuture<java.lang.Boolean[]>scriptExists(java.lang.String[] sha1s, RequestRoutingConfiguration.Route route)Checks existence of scripts in the script cache by their SHA1 digest.java.util.concurrent.CompletableFuture<java.lang.String>scriptFlush()Flushes the Lua scripts cache.
The command will be routed to all nodes.java.util.concurrent.CompletableFuture<java.lang.String>scriptFlush(FlushMode flushMode)Flushes the Lua scripts cache.
The command will be routed to all nodes.java.util.concurrent.CompletableFuture<java.lang.String>scriptFlush(FlushMode flushMode, RequestRoutingConfiguration.Route route)Flushes the Lua scripts cache.java.util.concurrent.CompletableFuture<java.lang.String>scriptFlush(RequestRoutingConfiguration.Route route)Flushes the Lua scripts cache.java.util.concurrent.CompletableFuture<java.lang.String>scriptKill()Kill the currently executing Lua script, assuming no write operation was yet performed by the script.
The command will be routed to all nodes.java.util.concurrent.CompletableFuture<java.lang.String>scriptKill(RequestRoutingConfiguration.Route route)Kills the currently executing Lua script, assuming no write operation was yet performed by the script.
-
-
-
Method Detail
-
functionLoad
java.util.concurrent.CompletableFuture<java.lang.String> functionLoad(java.lang.String libraryCode, boolean replace)Loads a library to Valkey.
The command will be routed to all primary nodes.- Parameters:
libraryCode- The source code that implements the library.replace- Whether the given library should overwrite a library with the same name if it already exists.- Returns:
- The library name that was loaded.
- Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for details.
- Example:
String code = "#!lua name=mylib \n redis.register_function('myfunc', function(keys, args) return args[1] end)"; String response = client.functionLoad(code, true).get(); assert response.equals("mylib");
-
functionLoad
java.util.concurrent.CompletableFuture<GlideString> functionLoad(GlideString libraryCode, boolean replace)
Loads a library to Valkey.
The command will be routed to all primary nodes.- Parameters:
libraryCode- The source code that implements the library.replace- Whether the given library should overwrite a library with the same name if it already exists.- Returns:
- The library name that was loaded.
- Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for details.
- Example:
GlideString code = gs("#!lua name=mylib \n redis.register_function('myfunc', function(keys, args) return args[1] end)"); GlideString response = client.functionLoad(code, true).get(); assert response.equals(gs("mylib"));
-
functionLoad
java.util.concurrent.CompletableFuture<java.lang.String> functionLoad(java.lang.String libraryCode, boolean replace, RequestRoutingConfiguration.Route route)Loads a library to Valkey.- Parameters:
libraryCode- The source code that implements the library.replace- Whether the given library should overwrite a library with the same name if it already exists.route- Specifies the routing configuration for the command. The client will route the command to the nodes defined byroute.- Returns:
- The library name that was loaded.
- Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for details.
- Example:
String code = "#!lua name=mylib \n redis.register_function('myfunc', function(keys, args) return args[1] end)"; Route route = new SlotKeyRoute("key", PRIMARY); String response = client.functionLoad(code, true, route).get(); assert response.equals("mylib");
-
functionLoad
java.util.concurrent.CompletableFuture<GlideString> functionLoad(GlideString libraryCode, boolean replace, RequestRoutingConfiguration.Route route)
Loads a library to Valkey.- Parameters:
libraryCode- The source code that implements the library.replace- Whether the given library should overwrite a library with the same name if it already exists.route- Specifies the routing configuration for the command. The client will route the command to the nodes defined byroute.- Returns:
- The library name that was loaded.
- Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for details.
- Example:
GlideString code = gs("#!lua name=mylib \n redis.register_function('myfunc', function(keys, args) return args[1] end)"); Route route = new SlotKeyRoute("key", PRIMARY); GlideString response = client.functionLoad(code, true, route).get(); assert response.equals(gs("mylib"));
-
functionList
java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,java.lang.Object>[]> functionList(boolean withCode)
Returns information about the functions and libraries.
The command will be routed to a random node.- Parameters:
withCode- Specifies whether to request the library code from the server or not.- Returns:
- Info about all libraries and their functions.
- Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for details.
- Example:
Map<String, Object>[] response = client.functionList(true).get(); for (Map<String, Object> libraryInfo : response) { System.out.printf("Server has library '%s' which runs on %s engine%n", libraryInfo.get("library_name"), libraryInfo.get("engine")); Map<String, Object>[] functions = (Map<String, Object>[]) libraryInfo.get("functions"); for (Map<String, Object> function : functions) { Set<String> flags = (Set<String>) function.get("flags"); System.out.printf("Library has function '%s' with flags '%s' described as %s%n", function.get("name"), String.join(", ", flags), function.get("description")); } System.out.printf("Library code:%n%s%n", libraryInfo.get("library_code")); }
-
functionListBinary
java.util.concurrent.CompletableFuture<java.util.Map<GlideString,java.lang.Object>[]> functionListBinary(boolean withCode)
Returns information about the functions and libraries.
The command will be routed to a random node.- Parameters:
withCode- Specifies whether to request the library code from the server or not.- Returns:
- Info about all libraries and their functions.
- Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for details.
- Example:
Map<GlideString, Object>[] response = client.functionList(true).get(); for (Map<GlideString, Object> libraryInfo : response) { System.out.printf("Server has library '%s' which runs on %s engine%n", libraryInfo.get(gs("library_name")), libraryInfo.get(gs("engine"))); Map<GlideString, Object>[] functions = (Map<GlideString, Object>[]) libraryInfo.get(gs("functions")); for (Map<GlideString, Object> function : functions) { Set<GlideString> flags = (Set<GlideString>) function.get(gs("flags")); System.out.printf("Library has function '%s' with flags '%s' described as %s%n", function.get(gs("name")), gs(String.join(", ", flags)), function.get(gs("description"))); } System.out.printf("Library code:%n%s%n", libraryInfo.get(gs("library_code"))); }
-
functionList
java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,java.lang.Object>[]> functionList(java.lang.String libNamePattern, boolean withCode)Returns information about the functions and libraries.
The command will be routed to a random node.- Parameters:
libNamePattern- A wildcard pattern for matching library names.withCode- Specifies whether to request the library code from the server or not.- Returns:
- Info about queried libraries and their functions.
- Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for details.
- Example:
Map<String, Object>[] response = client.functionList("myLib?_backup", true).get(); for (Map<String, Object> libraryInfo : response) { System.out.printf("Server has library '%s' which runs on %s engine%n", libraryInfo.get("library_name"), libraryInfo.get("engine")); Map<String, Object>[] functions = (Map<String, Object>[]) libraryInfo.get("functions"); for (Map<String, Object> function : functions) { Set<String> flags = (Set<String>) function.get("flags"); System.out.printf("Library has function '%s' with flags '%s' described as %s%n", function.get("name"), String.join(", ", flags), function.get("description")); } System.out.printf("Library code:%n%s%n", libraryInfo.get("library_code")); }
-
functionListBinary
java.util.concurrent.CompletableFuture<java.util.Map<GlideString,java.lang.Object>[]> functionListBinary(GlideString libNamePattern, boolean withCode)
Returns information about the functions and libraries.
The command will be routed to a random node.- Parameters:
libNamePattern- A wildcard pattern for matching library names.withCode- Specifies whether to request the library code from the server or not.- Returns:
- Info about queried libraries and their functions.
- Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for details.
- Example:
Map<GlideString, Object>[] response = client.functionList(gs("myLib?_backup"), true).get(); for (Map<GlideString, Object> libraryInfo : response) { System.out.printf("Server has library '%s' which runs on %s engine%n", libraryInfo.get(gs("library_name")), libraryInfo.get(gs("engine"))); Map<GlideString, Object>[] functions = (Map<GlideString, Object>[]) libraryInfo.get(gs("functions")); for (Map<GlideString, Object> function : functions) { Set<GlideString> flags = (Set<GlideString>) function.get(gs("flags")); System.out.printf("Library has function '%s' with flags '%s' described as %s%n", function.get(gs("name")), gs(String.join(", ", flags)), function.get(gs("description"))); } System.out.printf("Library code:%n%s%n", libraryInfo.get(gs("library_code"))); }
-
functionList
java.util.concurrent.CompletableFuture<ClusterValue<java.util.Map<java.lang.String,java.lang.Object>[]>> functionList(boolean withCode, RequestRoutingConfiguration.Route route)
Returns information about the functions and libraries.- Parameters:
withCode- Specifies whether to request the library code from the server or not.route- Specifies the routing configuration for the command. The client will route the command to the nodes defined byroute.- Returns:
- Info about all libraries and their functions.
- Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for details.
- Example:
ClusterValue<Map<String, Object>[]> response = client.functionList(true, ALL_NODES).get(); for (String node : response.getMultiValue().keySet()) { for (Map<String, Object> libraryInfo : response.getMultiValue().get(node)) { System.out.printf("Node '%s' has library '%s' which runs on %s engine%n", node, libraryInfo.get("library_name"), libraryInfo.get("engine")); Map<String, Object>[] functions = (Map<String, Object>[]) libraryInfo.get("functions"); for (Map<String, Object> function : functions) { Set<String> flags = (Set<String>) function.get("flags"); System.out.printf("Library has function '%s' with flags '%s' described as %s%n", function.get("name"), String.join(", ", flags), function.get("description")); } System.out.printf("Library code:%n%s%n", libraryInfo.get("library_code")); } }
-
functionListBinary
java.util.concurrent.CompletableFuture<ClusterValue<java.util.Map<GlideString,java.lang.Object>[]>> functionListBinary(boolean withCode, RequestRoutingConfiguration.Route route)
Returns information about the functions and libraries.- Parameters:
withCode- Specifies whether to request the library code from the server or not.route- Specifies the routing configuration for the command. The client will route the command to the nodes defined byroute.- Returns:
- Info about all libraries and their functions.
- Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for details.
- Example:
ClusterValue<Map<GlideString, Object>[]> response = client.functionList(true, ALL_NODES).get(); for (String node : response.getMultiValue().keySet()) { for (Map<GlideString, Object> libraryInfo : response) { System.out.printf("Server has library '%s' which runs on %s engine%n", libraryInfo.get(gs("library_name")), libraryInfo.get(gs("engine"))); Map<GlideString, Object>[] functions = (Map<GlideString, Object>[]) libraryInfo.get(gs("functions")); for (Map<GlideString, Object> function : functions) { Set<GlideString> flags = (Set<GlideString>) function.get(gs("flags")); System.out.printf("Library has function '%s' with flags '%s' described as %s%n", function.get(gs("name")), gs(String.join(", ", flags)), function.get(gs("description"))); } System.out.printf("Library code:%n%s%n", libraryInfo.get(gs("library_code"))); } }
-
functionList
java.util.concurrent.CompletableFuture<ClusterValue<java.util.Map<java.lang.String,java.lang.Object>[]>> functionList(java.lang.String libNamePattern, boolean withCode, RequestRoutingConfiguration.Route route)
Returns information about the functions and libraries.- Parameters:
libNamePattern- A wildcard pattern for matching library names.withCode- Specifies whether to request the library code from the server or not.route- Specifies the routing configuration for the command. The client will route the command to the nodes defined byroute.- Returns:
- Info about queried libraries and their functions.
- Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for details.
- Example:
ClusterValue<Map<String, Object>[]> response = client.functionList("myLib?_backup", true, ALL_NODES).get(); for (String node : response.getMultiValue().keySet()) { for (Map<String, Object> libraryInfo : response.getMultiValue().get(node)) { System.out.printf("Node '%s' has library '%s' which runs on %s engine%n", node, libraryInfo.get("library_name"), libraryInfo.get("engine")); Map<String, Object>[] functions = (Map<String, Object>[]) libraryInfo.get("functions"); for (Map<String, Object> function : functions) { Set<String> flags = (Set<String>) function.get("flags"); System.out.printf("Library has function '%s' with flags '%s' described as %s%n", function.get("name"), String.join(", ", flags), function.get("description")); } System.out.printf("Library code:%n%s%n", libraryInfo.get("library_code")); } }
-
functionListBinary
java.util.concurrent.CompletableFuture<ClusterValue<java.util.Map<GlideString,java.lang.Object>[]>> functionListBinary(GlideString libNamePattern, boolean withCode, RequestRoutingConfiguration.Route route)
Returns information about the functions and libraries.- Parameters:
libNamePattern- A wildcard pattern for matching library names.withCode- Specifies whether to request the library code from the server or not.route- Specifies the routing configuration for the command. The client will route the command to the nodes defined byroute.- Returns:
- Info about queried libraries and their functions.
- Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for details.
- Example:
ClusterValue<Map<String, Object>[]> response = client.functionList(gs("myLib?_backup"), true, ALL_NODES).get(); for (String node : response.getMultiValue().keySet()) { for (Map<GlideString, Object> libraryInfo : response) { System.out.printf("Server has library '%s' which runs on %s engine%n", libraryInfo.get(gs("library_name")), libraryInfo.get(gs("engine"))); Map<GlideString, Object>[] functions = (Map<GlideString, Object>[]) libraryInfo.get(gs("functions")); for (Map<GlideString, Object> function : functions) { Set<GlideString> flags = (Set<GlideString>) function.get(gs("flags")); System.out.printf("Library has function '%s' with flags '%s' described as %s%n", function.get(gs("name")), gs(String.join(", ", flags)), function.get(gs("description"))); } System.out.printf("Library code:%n%s%n", libraryInfo.get(gs("library_code"))); } }
-
functionFlush
java.util.concurrent.CompletableFuture<java.lang.String> functionFlush()
Deletes all function libraries.
The command will be routed to all primary nodes.- Returns:
OK.- Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for details.
- Example:
String response = client.functionFlush().get(); assert response.equals("OK");
-
functionFlush
java.util.concurrent.CompletableFuture<java.lang.String> functionFlush(FlushMode mode)
Deletes all function libraries.
The command will be routed to all primary nodes.- Parameters:
mode- The flushing mode, could be eitherFlushMode.SYNCorFlushMode.ASYNC.- Returns:
OK.- Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for details.
- Example:
String response = client.functionFlush(SYNC).get(); assert response.equals("OK");
-
functionFlush
java.util.concurrent.CompletableFuture<java.lang.String> functionFlush(RequestRoutingConfiguration.Route route)
Deletes all function libraries.- Parameters:
route- Specifies the routing configuration for the command. The client will route the command to the nodes defined byroute.- Returns:
OK.- Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for details.
- Example:
String response = client.functionFlush(RANDOM).get(); assert response.equals("OK");
-
functionFlush
java.util.concurrent.CompletableFuture<java.lang.String> functionFlush(FlushMode mode, RequestRoutingConfiguration.Route route)
Deletes all function libraries.- Parameters:
mode- The flushing mode, could be eitherFlushMode.SYNCorFlushMode.ASYNC.route- Specifies the routing configuration for the command. The client will route the command to the nodes defined byroute.- Returns:
OK.- Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for details.
- Example:
String response = client.functionFlush(SYNC, RANDOM).get(); assert response.equals("OK");
-
functionDelete
java.util.concurrent.CompletableFuture<java.lang.String> functionDelete(java.lang.String libName)
Deletes a library and all its functions.
The command will be routed to all primary nodes.- Parameters:
libName- The library name to delete.- Returns:
OK.- Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for details.
- Example:
String response = client.functionDelete("myLib").get(); assert response.equals("OK");
-
functionDelete
java.util.concurrent.CompletableFuture<java.lang.String> functionDelete(GlideString libName)
Deletes a library and all its functions.
The command will be routed to all primary nodes.- Parameters:
libName- The library name to delete.- Returns:
OK.- Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for details.
- Example:
String response = client.functionDelete(gs("myLib")).get(); assert response.equals("OK");
-
functionDelete
java.util.concurrent.CompletableFuture<java.lang.String> functionDelete(java.lang.String libName, RequestRoutingConfiguration.Route route)Deletes a library and all its functions.- Parameters:
libName- The library name to delete.route- Specifies the routing configuration for the command. The client will route the command to the nodes defined byroute.- Returns:
OK.- Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for details.
- Example:
String response = client.functionDelete("myLib", RANDOM).get(); assert response.equals("OK");
-
functionDelete
java.util.concurrent.CompletableFuture<java.lang.String> functionDelete(GlideString libName, RequestRoutingConfiguration.Route route)
Deletes a library and all its functions.- Parameters:
libName- The library name to delete.route- Specifies the routing configuration for the command. The client will route the command to the nodes defined byroute.- Returns:
OK.- Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for details.
- Example:
String response = client.functionDelete(gs("myLib"), RANDOM).get(); assert response.equals("OK");
-
functionDump
java.util.concurrent.CompletableFuture<byte[]> functionDump()
Returns the serialized payload of all loaded libraries.
The command will be routed to a random node.- Returns:
- The serialized payload of all loaded libraries.
- Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for details.
- Example:
byte[] data = client.functionDump().get(); // data can be used to restore loaded functions on any Valkey instance
-
functionDump
java.util.concurrent.CompletableFuture<ClusterValue<byte[]>> functionDump(RequestRoutingConfiguration.Route route)
Returns the serialized payload of all loaded libraries.- Parameters:
route- Specifies the routing configuration for the command. The client will route the command to the nodes defined byroute.- Returns:
- The serialized payload of all loaded libraries.
- Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for details.
- Example:
byte[] data = client.functionDump(RANDOM).get().getSingleValue(); // data can be used to restore loaded functions on any Valkey instance
-
functionRestore
java.util.concurrent.CompletableFuture<java.lang.String> functionRestore(byte[] payload)
Restores libraries from the serialized payload returned byfunctionDump().
The command will be routed to all primary nodes.- Parameters:
payload- The serialized data fromfunctionDump().- Returns:
OK.- Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for details.
- Example:
String response = client.functionRestore(data).get(); assert response.equals("OK");
-
functionRestore
java.util.concurrent.CompletableFuture<java.lang.String> functionRestore(byte[] payload, FunctionRestorePolicy policy)Restores libraries from the serialized payload returned byfunctionDump().
The command will be routed to all primary nodes.- Parameters:
payload- The serialized data fromfunctionDump().policy- A policy for handling existing libraries.- Returns:
OK.- Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for details.
- Example:
String response = client.functionRestore(data, FLUSH).get(); assert response.equals("OK");
-
functionRestore
java.util.concurrent.CompletableFuture<java.lang.String> functionRestore(byte[] payload, RequestRoutingConfiguration.Route route)Restores libraries from the serialized payload returned byfunctionDump(Route).- Parameters:
payload- The serialized data fromfunctionDump().route- Specifies the routing configuration for the command. The client will route the command to the nodes defined byroute.- Returns:
OK.- Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for details.
- Example:
String response = client.functionRestore(data, ALL_PRIMARIES).get(); assert response.equals("OK");
-
functionRestore
java.util.concurrent.CompletableFuture<java.lang.String> functionRestore(byte[] payload, FunctionRestorePolicy policy, RequestRoutingConfiguration.Route route)Restores libraries from the serialized payload returned byfunctionDump(Route).- Parameters:
payload- The serialized data fromfunctionDump().policy- A policy for handling existing libraries.route- Specifies the routing configuration for the command. The client will route the command to the nodes defined byroute.- Returns:
OK.- Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for details.
- Example:
String response = client.functionRestore(data, FLUSH, ALL_PRIMARIES).get(); assert response.equals("OK");
-
fcall
java.util.concurrent.CompletableFuture<java.lang.Object> fcall(java.lang.String function)
Invokes a previously loaded function.
The command will be routed to a primary random node.
To route to a replica please refer tofcallReadOnly(String).- Parameters:
function- The function name.- Returns:
- The invoked function's return value.
- Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for details.
- Example:
Object response = client.fcall("Deep_Thought").get(); assert response == 42L;
-
fcall
java.util.concurrent.CompletableFuture<java.lang.Object> fcall(GlideString function)
Invokes a previously loaded function.
The command will be routed to a primary random node.
To route to a replica please refer tofcallReadOnly(String).- Parameters:
function- The function name.- Returns:
- The invoked function's return value.
- Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for details.
- Example:
Object response = client.fcall(gs("Deep_Thought")).get(); assert response == 42L;
-
fcall
java.util.concurrent.CompletableFuture<ClusterValue<java.lang.Object>> fcall(java.lang.String function, RequestRoutingConfiguration.Route route)
Invokes a previously loaded function.- Parameters:
function- The function name.route- Specifies the routing configuration for the command. The client will route the command to the nodes defined byroute.- Returns:
- The invoked function's return value wrapped by a
ClusterValue. - Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for details.
- Example:
ClusterValue<Object> response = client.fcall("Deep_Thought", ALL_NODES).get(); for (Object nodeResponse : response.getMultiValue().values()) { assert nodeResponse == 42L; }
-
fcall
java.util.concurrent.CompletableFuture<ClusterValue<java.lang.Object>> fcall(GlideString function, RequestRoutingConfiguration.Route route)
Invokes a previously loaded function.- Parameters:
function- The function name.route- Specifies the routing configuration for the command. The client will route the command to the nodes defined byroute.- Returns:
- The invoked function's return value wrapped by a
ClusterValue. - Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for details.
- Example:
ClusterValue<Object> response = client.fcall(gs("Deep_Thought"), ALL_NODES).get(); for (Object nodeResponse : response.getMultiValue().values()) { assert nodeResponse == 42L; }
-
fcall
java.util.concurrent.CompletableFuture<java.lang.Object> fcall(java.lang.String function, java.lang.String[] arguments)Invokes a previously loaded function.
The command will be routed to a random primary node.
To route to a replica please refer tofcallReadOnly(String, String[]).- Parameters:
function- The function name.arguments- Anarrayoffunctionarguments.argumentsshould not represent names of keys.- Returns:
- The invoked function's return value.
- Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for details.
- Example:
String[] args = new String[] { "Answer", "to", "the", "Ultimate", "Question", "of", "Life,", "the", "Universe,", "and", "Everything" }; Object response = client.fcall("Deep_Thought", args).get(); assert response == 42L;
-
fcall
java.util.concurrent.CompletableFuture<java.lang.Object> fcall(GlideString function, GlideString[] arguments)
Invokes a previously loaded function.
The command will be routed to a random primary node.
To route to a replica please refer tofcallReadOnly(String, String[]).- Parameters:
function- The function name.arguments- Anarrayoffunctionarguments.argumentsshould not represent names of keys.- Returns:
- The invoked function's return value.
- Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for details.
- Example:
GlideString[] args = new GlideString[] { gs("Answer"), gs("to"), gs("the"), gs("Ultimate"), gs("Question"), gs("of"), gs("Life,"), gs("the"), gs("Universe,"), gs("and"), gs("Everything")}; Object response = client.fcall(gs("Deep_Thought"), args).get(); assert response == 42L;
-
fcall
java.util.concurrent.CompletableFuture<ClusterValue<java.lang.Object>> fcall(java.lang.String function, java.lang.String[] arguments, RequestRoutingConfiguration.Route route)
Invokes a previously loaded function.- Parameters:
function- The function name.arguments- Anarrayoffunctionarguments.argumentsshould not represent names of keys.route- Specifies the routing configuration for the command. The client will route the command to the nodes defined byroute.- Returns:
- The invoked function's return value wrapped by a
ClusterValue. - Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for details.
- Example:
String[] args = new String[] { "Answer", "to", "the", "Ultimate", "Question", "of", "Life,", "the", "Universe,", "and", "Everything" }; ClusterValue<Object> response = client.fcall("Deep_Thought", args, RANDOM).get(); assert response.getSingleValue() == 42L;
-
fcall
java.util.concurrent.CompletableFuture<ClusterValue<java.lang.Object>> fcall(GlideString function, GlideString[] arguments, RequestRoutingConfiguration.Route route)
Invokes a previously loaded function.- Parameters:
function- The function name.arguments- Anarrayoffunctionarguments.argumentsshould not represent names of keys.route- Specifies the routing configuration for the command. The client will route the command to the nodes defined byroute.- Returns:
- The invoked function's return value wrapped by a
ClusterValue. - Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for details.
- Example:
GlideString[] args = new GlideString[] { gs("Answer"), gs("to"), gs("the"), gs("Ultimate"), gs("Question"), gs("of"), gs("Life,"), gs("the"), gs("Universe,"), gs("and"), gs("Everything")}; ClusterValue<Object> response = client.fcall(gs("Deep_Thought"), args, RANDOM).get(); assert response.getSingleValue() == 42L;
-
fcallReadOnly
java.util.concurrent.CompletableFuture<java.lang.Object> fcallReadOnly(java.lang.String function)
Invokes a previously loaded read-only function.
The command is routed to a random node depending on the client'sReadFromstrategy.- Parameters:
function- The function name.- Returns:
- The invoked function's return value.
- Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for details.
- Example:
Object response = client.fcallReadOnly("Deep_Thought").get(); assert response == 42L;
-
fcallReadOnly
java.util.concurrent.CompletableFuture<java.lang.Object> fcallReadOnly(GlideString function)
Invokes a previously loaded read-only function.
The command is routed to a random node depending on the client'sReadFromstrategy.- Parameters:
function- The function name.- Returns:
- The invoked function's return value.
- Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for details.
- Example:
Object response = client.fcallReadOnly(gs("Deep_Thought")).get(); assert response == 42L;
-
fcallReadOnly
java.util.concurrent.CompletableFuture<ClusterValue<java.lang.Object>> fcallReadOnly(java.lang.String function, RequestRoutingConfiguration.Route route)
Invokes a previously loaded read-only function.- Parameters:
function- The function name.route- Specifies the routing configuration for the command. The client will route the command to the nodes defined byroute.- Returns:
- The invoked function's return value wrapped by a
ClusterValue. - Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for details.
- Example:
ClusterValue<Object> response = client.fcallReadOnly("Deep_Thought", ALL_NODES).get(); for (Object nodeResponse : response.getMultiValue().values()) { assert nodeResponse == 42L; }
-
fcallReadOnly
java.util.concurrent.CompletableFuture<ClusterValue<java.lang.Object>> fcallReadOnly(GlideString function, RequestRoutingConfiguration.Route route)
Invokes a previously loaded read-only function.- Parameters:
function- The function name.route- Specifies the routing configuration for the command. The client will route the command to the nodes defined byroute.- Returns:
- The invoked function's return value wrapped by a
ClusterValue. - Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for details.
- Example:
ClusterValue<Object> response = client.fcallReadOnly(gs("Deep_Thought"), ALL_NODES).get(); for (Object nodeResponse : response.getMultiValue().values()) { assert nodeResponse == 42L; }
-
fcallReadOnly
java.util.concurrent.CompletableFuture<java.lang.Object> fcallReadOnly(java.lang.String function, java.lang.String[] arguments)Invokes a previously loaded function.
The command is routed to a random node depending on the client'sReadFromstrategy.- Parameters:
function- The function name.arguments- Anarrayoffunctionarguments.argumentsshould not represent names of keys.- Returns:
- The invoked function's return value.
- Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for details.
- Example:
String[] args = new String[] { "Answer", "to", "the", "Ultimate", "Question", "of", "Life,", "the", "Universe,", "and", "Everything" }; Object response = client.fcallReadOnly("Deep_Thought", args).get(); assert response == 42L;
-
fcallReadOnly
java.util.concurrent.CompletableFuture<java.lang.Object> fcallReadOnly(GlideString function, GlideString[] arguments)
Invokes a previously loaded function.
The command is routed to a random node depending on the client'sReadFromstrategy.- Parameters:
function- The function name.arguments- Anarrayoffunctionarguments.argumentsshould not represent names of keys.- Returns:
- The invoked function's return value.
- Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for details.
- Example:
GlideString[] args = new GlideString[] { gs("Answer"), gs("to"), gs("the"), gs("Ultimate"), gs("Question"), gs("of"), gs("Life,"), gs("the"), gs("Universe,"), gs("and"), gs("Everything")}; Object response = client.fcallReadOnly(gs("Deep_Thought"), args).get(); assert response == 42L;
-
fcallReadOnly
java.util.concurrent.CompletableFuture<ClusterValue<java.lang.Object>> fcallReadOnly(java.lang.String function, java.lang.String[] arguments, RequestRoutingConfiguration.Route route)
Invokes a previously loaded read-only function.- Parameters:
function- The function name.arguments- Anarrayoffunctionarguments.argumentsshould not represent names of keys.route- Specifies the routing configuration for the command. The client will route the command to the nodes defined byroute.- Returns:
- The invoked function's return value wrapped by a
ClusterValue. - Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for details.
- Example:
String[] args = new String[] { "Answer", "to", "the", "Ultimate", "Question", "of", "Life,", "the", "Universe,", "and", "Everything" }; ClusterValue<Object> response = client.fcallReadOnly("Deep_Thought", args, RANDOM).get(); assert response.getSingleValue() == 42L;
-
fcallReadOnly
java.util.concurrent.CompletableFuture<ClusterValue<java.lang.Object>> fcallReadOnly(GlideString function, GlideString[] arguments, RequestRoutingConfiguration.Route route)
Invokes a previously loaded read-only function.- Parameters:
function- The function name.arguments- Anarrayoffunctionarguments.argumentsshould not represent names of keys.route- Specifies the routing configuration for the command. The client will route the command to the nodes defined byroute.- Returns:
- The invoked function's return value wrapped by a
ClusterValue. - Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for details.
- Example:
GlideString[] args = new GlideString[] { gs("Answer"), gs("to"), gs("the"), gs("Ultimate"), gs("Question"), gs("of"), gs("Life,"), gs("the"), gs("Universe,"), gs("and"), gs("Everything")}; ClusterValue<Object> response = client.fcallReadOnly(gs("Deep_Thought"), args, RANDOM).get(); assert response.getSingleValue() == 42L;
-
functionKill
java.util.concurrent.CompletableFuture<java.lang.String> functionKill()
Kills a function that is currently executing.
FUNCTION KILLterminates read-only functions only.
The command will be routed to all nodes.- Returns:
OKif function is terminated. Otherwise, throws an error.- Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for details.
- Example:
String response = client.functionKill().get(); assert response.equals("OK");
-
functionKill
java.util.concurrent.CompletableFuture<java.lang.String> functionKill(RequestRoutingConfiguration.Route route)
Kills a function that is currently executing.
FUNCTION KILLterminates read-only functions only.- Parameters:
route- Specifies the routing configuration for the command. The client will route the command to the nodes defined byroute.- Returns:
OKif function is terminated. Otherwise, throws an error.- Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for details.
- Example:
String response = client.functionKill(RANDOM).get(); assert response.equals("OK");
-
functionStats
java.util.concurrent.CompletableFuture<ClusterValue<java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.Object>>>> functionStats()
Returns information about the function that's currently running and information about the available execution engines.
The command will be routed to all nodes.- Returns:
- A
Mapwith two keys:running_scriptwith information about the running script.engineswith information about available engines and their stats.
- Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for details.
- Example:
Map<String, Map<String, Map<String, Object>>> response = client.functionStats().get().getMultiValue(); for (String node : response.keySet()) { Map<String, Object> runningScriptInfo = response.get(node).get("running_script"); if (runningScriptInfo != null) { String[] commandLine = (String[]) runningScriptInfo.get("command"); System.out.printf("Node '%s' is currently running function '%s' with command line '%s', which has been running for %d ms%n", node, runningScriptInfo.get("name"), String.join(" ", commandLine), (long) runningScriptInfo.get("duration_ms")); } Map<String, Object> enginesInfo = response.get(node).get("engines"); for (String engineName : enginesInfo.keySet()) { Map<String, Long> engine = (Map<String, Long>) enginesInfo.get(engineName); System.out.printf("Node '%s' supports engine '%s', which has %d libraries and %d functions in total%n", node, engineName, engine.get("libraries_count"), engine.get("functions_count")); } }
-
functionStatsBinary
java.util.concurrent.CompletableFuture<ClusterValue<java.util.Map<GlideString,java.util.Map<GlideString,java.lang.Object>>>> functionStatsBinary()
Returns information about the function that's currently running and information about the available execution engines.
The command will be routed to all nodes.- Returns:
- A
Mapwith two keys:running_scriptwith information about the running script.engineswith information about available engines and their stats.
- Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for details.
- Example:
Map<String, Map<GlideString, Map<GlideString, Object>>> response = client.functionStatsBinary().get().getMultiValue(); for (GlideString node : response.keySet()) { Map<GlideString, Object> runningScriptInfo = response.get(node).get(gs("running_script")); if (runningScriptInfo != null) { GlideString[] commandLine = (GlideString[]) runningScriptInfo.get(gs("command")); System.out.printf("Node '%s' is currently running function '%s' with command line '%s', which has been running for %d ms%n", node, runningScriptInfo.get(gs("name")), String.join(" ", Arrays.toString(commandLine)), (long) runningScriptInfo.get(gs("duration_ms"))); } Map<GlideString, Object> enginesInfo = response.get(node).get(gs("engines")); for (String engineName : enginesInfo.keySet()) { Map<GlideString, Long> engine = (Map<GlideString, Long>) enginesInfo.get(engineName); System.out.printf("Node '%s' supports engine '%s', which has %d libraries and %d functions in total%n", node, engineName, engine.get(gs("libraries_count")), engine.get(gs("functions_count"))); } }
-
functionStats
java.util.concurrent.CompletableFuture<ClusterValue<java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.Object>>>> functionStats(RequestRoutingConfiguration.Route route)
Returns information about the function that's currently running and information about the available execution engines.- Parameters:
route- Specifies the routing configuration for the command. The client will route the command to the nodes defined byroute.- Returns:
- A
Mapwith two keys:running_scriptwith information about the running script.engineswith information about available engines and their stats.
- Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for details.
- Example:
Map<String, Map<String, Object>> response = client.functionStats(RANDOM).get().getSingleValue(); Map<String, Object> runningScriptInfo = response.get("running_script"); if (runningScriptInfo != null) { String[] commandLine = (String[]) runningScriptInfo.get("command"); System.out.printf("Node is currently running function '%s' with command line '%s', which has been running for %d ms%n", runningScriptInfo.get("name"), String.join(" ", commandLine), (long)runningScriptInfo.get("duration_ms")); } Map<String, Object> enginesInfo = response.get("engines"); for (String engineName : enginesInfo.keySet()) { Map<String, Long> engine = (Map<String, Long>) enginesInfo.get(engineName); System.out.printf("Node supports engine '%s', which has %d libraries and %d functions in total%n", engineName, engine.get("libraries_count"), engine.get("functions_count")); }
-
functionStatsBinary
java.util.concurrent.CompletableFuture<ClusterValue<java.util.Map<GlideString,java.util.Map<GlideString,java.lang.Object>>>> functionStatsBinary(RequestRoutingConfiguration.Route route)
Returns information about the function that's currently running and information about the available execution engines.- Parameters:
route- Specifies the routing configuration for the command. The client will route the command to the nodes defined byroute.- Returns:
- A
Mapwith two keys:running_scriptwith information about the running script.engineswith information about available engines and their stats.
- Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for details.
- Example:
Map<GlideString, Map<GlideString, Object>> response = client.functionStats(RANDOM).get().getSingleValue(); Map<GlideString, Object> runningScriptInfo = response.get(gs("running_script")); if (runningScriptInfo != null) { GlideString[] commandLine = (GlideString[]) runningScriptInfo.get(gs("command")); System.out.printf("Node is currently running function '%s' with command line '%s', which has been running for %d ms%n", runningScriptInfo.get(gs("name")), String.join(" ", Arrays.toString(commandLine)), (long)runningScriptInfo.get(gs("duration_ms"))); } Map<GlideString, Object> enginesInfo = response.get(gs("engines")); for (GlideString engineName : enginesInfo.keySet()) { Map<GlideString, Long> engine = (Map<GlideString, Long>) enginesInfo.get(engineName); System.out.printf("Node supports engine '%s', which has %d libraries and %d functions in total%n", engineName, engine.get(gs("libraries_count")), engine.get(gs("functions_count"))); }
-
invokeScript
java.util.concurrent.CompletableFuture<java.lang.Object> invokeScript(Script script, RequestRoutingConfiguration.Route route)
Invokes a Lua script.
This method simplifies the process of invoking scripts on the server by using an object that represents a Lua script. The script loading and execution will all be handled internally. If the script has not already been loaded, it will be loaded automatically using theSCRIPT LOADcommand. After that, it will be invoked using theEVALSHAcommand.- Parameters:
script- The Lua script to execute.route- Specifies the routing configuration for the command. The client will route the command to the nodes defined byroute.- Returns:
- A value that depends on the script that was executed.
- See Also:
- SCRIPT LOAD and EVALSHA for details.
- Example:
try(Script luaScript = new Script("return 'Hello'", false)) { String result = (String) client.invokeScript(luaScript).get(); assert result.equals("Hello"); }
-
invokeScript
java.util.concurrent.CompletableFuture<java.lang.Object> invokeScript(Script script, ScriptArgOptions options, RequestRoutingConfiguration.Route route)
Invokes a Lua script with its keys and arguments.
This method simplifies the process of invoking scripts on the server by using an object that represents a Lua script. The script loading, argument preparation, and execution will all be handled internally. If the script has not already been loaded, it will be loaded automatically using theSCRIPT LOADcommand. After that, it will be invoked using theEVALSHAcommand.- Parameters:
script- The Lua script to execute.options- The script option that contains the non-key arguments for the script.route- Specifies the routing configuration for the command. The client will route the command to the nodes defined byroute.- Returns:
- A value that depends on the script that was executed.
- See Also:
- SCRIPT LOAD and EVALSHA for details.
- Example:
try(Script luaScript = new Script("return { ARGV[1] }", false)) { ScriptArgOptions scriptArgOptions = ScriptArgOptions.builder().arg("abc").build(); Object[] result = (Object[]) client.invokeScript(luaScript, scriptOptions, ALL_PRIMARIES).get(); assert result[0].equals("abc"); }
-
invokeScript
java.util.concurrent.CompletableFuture<java.lang.Object> invokeScript(Script script, ScriptArgOptionsGlideString options, RequestRoutingConfiguration.Route route)
Invokes a Lua script with its keys and arguments.
This method simplifies the process of invoking scripts on the server by using an object that represents a Lua script. The script loading, argument preparation, and execution will all be handled internally. If the script has not already been loaded, it will be loaded automatically using theSCRIPT LOADcommand. After that, it will be invoked using theEVALSHAcommand.- Parameters:
script- The Lua script to execute.options- The script option that contains the non-key arguments for the script.route- Specifies the routing configuration for the command. The client will route the command to the nodes defined byroute.- Returns:
- A value that depends on the script that was executed.
- See Also:
- SCRIPT LOAD and EVALSHA for details.
- Example:
try(Script luaScript = new Script(gs("return { ARGV[1] }", true))) { ScriptArgOptionsGlideString options = ScriptArgOptions.builder().arg(gs("abc")).build(); Object[] result = (Object[]) client.invokeScript(luaScript, options, ALL_PRIMARIES).get(); assert result[0].equals(gs("abc")); }
-
scriptExists
java.util.concurrent.CompletableFuture<java.lang.Boolean[]> scriptExists(java.lang.String[] sha1s)
Checks existence of scripts in the script cache by their SHA1 digest.
The command will be routed to all primary nodes.- Parameters:
sha1s- SHA1 digests of Lua scripts to be checked.- Returns:
- An array of
booleanvalues indicating the existence of each script. - See Also:
- SCRIPT EXISTS for details.
- Example:
try(Script luaScript = new Script("return { KEYS[1], ARGV[1] }", true)) { client.invokeScript(luaScript).get(); Boolean[] result = client.scriptExists(new String[]{luaScript.getHash()}); assert result[0].equals(true); }
-
scriptExists
java.util.concurrent.CompletableFuture<java.lang.Boolean[]> scriptExists(GlideString[] sha1s)
Checks existence of scripts in the script cache by their SHA1 digest.
The command will be routed to all primary nodes.- Parameters:
sha1s- SHA1 digests of Lua scripts to be checked.- Returns:
- An array of
booleanvalues indicating the existence of each script. - See Also:
- SCRIPT EXISTS for details.
- Example:
try(Script luaScript = new Script(gs("return { KEYS[1], ARGV[1] }", true))) { client.invokeScript(luaScript).get(); Boolean[] result = client.scriptExists(new String[]{luaScript.getHash()}); assert result[0].equals(true); }
-
scriptExists
java.util.concurrent.CompletableFuture<java.lang.Boolean[]> scriptExists(java.lang.String[] sha1s, RequestRoutingConfiguration.Route route)Checks existence of scripts in the script cache by their SHA1 digest.- Parameters:
sha1s- SHA1 digests of Lua scripts to be checked.route- Specifies the routing configuration for the command. The client will route the command to the nodes defined byroute.- Returns:
- An array of
booleanvalues indicating the existence of each script. - See Also:
- SCRIPT EXISTS for details.
- Example:
try(Script luaScript = new Script("return { KEYS[1], ARGV[1] }", true)) { client.invokeScript(luaScript).get(); Boolean[] result = client.scriptExists(new String[]{luaScript.getHash()}); assert result[0].equals(true); }
-
scriptExists
java.util.concurrent.CompletableFuture<java.lang.Boolean[]> scriptExists(GlideString[] sha1s, RequestRoutingConfiguration.Route route)
Checks existence of scripts in the script cache by their SHA1 digest.- Parameters:
sha1s- SHA1 digests of Lua scripts to be checked.route- Specifies the routing configuration for the command. The client will route the command to the nodes defined byroute.- Returns:
- An array of
booleanvalues indicating the existence of each script. - See Also:
- SCRIPT EXISTS for details.
- Example:
try(Script luaScript = new Script(gs("return { KEYS[1], ARGV[1] }", true))) { client.invokeScript(luaScript).get(); Boolean[] result = client.scriptExists(new String[]{luaScript.getHash()}); assert result[0].equals(true); }
-
scriptFlush
java.util.concurrent.CompletableFuture<java.lang.String> scriptFlush()
Flushes the Lua scripts cache.
The command will be routed to all nodes.- Returns:
- A simple "OK" response.
- See Also:
- SCRIPT FLUSH for details.
- Example:
String result = client.scriptFlush(); assert "OK".equals(result);
-
scriptFlush
java.util.concurrent.CompletableFuture<java.lang.String> scriptFlush(FlushMode flushMode)
Flushes the Lua scripts cache.
The command will be routed to all nodes.- Parameters:
flushMode- The flushing mode, could be eitherFlushMode.SYNCorFlushMode.ASYNC.- Returns:
- A simple "OK" response.
- See Also:
- SCRIPT FLUSH for details.
- Example:
String result = client.scriptFlush(ASYNC); assert "OK".equals(result);
-
scriptFlush
java.util.concurrent.CompletableFuture<java.lang.String> scriptFlush(RequestRoutingConfiguration.Route route)
Flushes the Lua scripts cache.- Parameters:
route- Specifies the routing configuration for the command. The client will route the command to the nodes defined byroute.- Returns:
- A simple "OK" response.
- See Also:
- SCRIPT flush for details.
- Example:
String result = client.scriptFlush(ALL_PRIMARIES); assert "OK".equals(result);
-
scriptFlush
java.util.concurrent.CompletableFuture<java.lang.String> scriptFlush(FlushMode flushMode, RequestRoutingConfiguration.Route route)
Flushes the Lua scripts cache.- Parameters:
flushMode- The flushing mode, could be eitherFlushMode.SYNCorFlushMode.ASYNC.route- Specifies the routing configuration for the command. The client will route the command to the nodes defined byroute.- Returns:
- A simple "OK" response.
- See Also:
- SCRIPT flush for details.
- Example:
String result = client.scriptFlush(ASYNC, ALL_PRIMARIES); assert "OK".equals(result);
-
scriptKill
java.util.concurrent.CompletableFuture<java.lang.String> scriptKill()
Kill the currently executing Lua script, assuming no write operation was yet performed by the script.
The command will be routed to all nodes.- Returns:
- A simple "OK" response.
- See Also:
- SCRIPT KILL for details.
- Example:
String result = client.scriptKill(); assert "OK".equals(result);
-
scriptKill
java.util.concurrent.CompletableFuture<java.lang.String> scriptKill(RequestRoutingConfiguration.Route route)
Kills the currently executing Lua script, assuming no write operation was yet performed by the script.- Parameters:
route- Specifies the routing configuration for the command. The client will route the command to the nodes defined byroute.- Returns:
- A simple "OK" response.
- See Also:
- SCRIPT KILL for details.
- Example:
String result = client.scriptKill(RANDOM); assert "OK".equals(result);
-
-