Package glide.api

Class GlideClient

    • Constructor Detail

      • GlideClient

        protected GlideClient​(BaseClient.ClientBuilder builder)
        Constructor using ClientParams from BaseClient.
    • Method Detail

      • createClient

        public static java.util.concurrent.CompletableFuture<GlideClient> createClient​(@NonNull
                                                                                       @NonNull GlideClientConfiguration config)
        Creates a new GlideClient instance and establishes a connection to a standalone Valkey
        Parameters:
        config - The configuration options for the client, including server addresses, authentication credentials, TLS settings, database selection, reconnection strategy, and Pub/Sub subscriptions.
        Returns:
        A Future that resolves to a connected GlideClient instance.
        Example:
        
         GlideClientConfiguration config =
             GlideClientConfiguration.builder()
                 .address(node1address)
                 .address(node2address)
                 .useTLS(true)
                 .readFrom(ReadFrom.PREFER_REPLICA)
                 .credentials(credentialsConfiguration)
                 .requestTimeout(2000)
                 .clientName("GLIDE")
                 .subscriptionConfiguration(
                     StandaloneSubscriptionConfiguration.builder()
                         .subscription(EXACT, "notifications")
                         .subscription(EXACT, "news")
                         .callback(callback)
                         .build())
                 .inflightRequestsLimit(1000)
                 .build();
         GlideClient client = GlideClient.createClient(config).get();
         
      • customCommand

        public java.util.concurrent.CompletableFuture<java.lang.Object> customCommand​(@NonNull
                                                                                      @NonNull java.lang.String[] args)
        Description copied from interface: GenericCommands
        Executes a single command, without checking inputs. Every part of the command, including subcommands, should be added as a separate value in args.
        Specified by:
        customCommand in interface GenericCommands
        Parameters:
        args - Arguments for the custom command.
        Returns:
        The returned value for the custom command.
        See Also:
        Valkey GLIDE Wiki for details on the restrictions and limitations of the custom command API.
      • customCommand

        public java.util.concurrent.CompletableFuture<java.lang.Object> customCommand​(@NonNull
                                                                                      @NonNull GlideString[] args)
        Description copied from interface: GenericCommands
        Executes a single command, without checking inputs. Every part of the command, including subcommands, should be added as a separate value in args.
        Specified by:
        customCommand in interface GenericCommands
        Parameters:
        args - Arguments for the custom command.
        Returns:
        The returned value for the custom command.
        See Also:
        Valkey GLIDE Wiki for details on the restrictions and limitations of the custom command API.
      • exec

        @Deprecated
        public java.util.concurrent.CompletableFuture<java.lang.Object[]> exec​(@NonNull
                                                                               @NonNull Transaction transaction)
        Deprecated.
        Specified by:
        exec in interface TransactionsCommands
        Parameters:
        transaction - A Transaction object containing a list of commands to be executed.
        Returns:
        A list of results corresponding to the execution of each command in the transaction.
        See Also:
        TransactionsCommands.exec(Batch, boolean), valkey.io for details on Transactions.
      • exec

        public java.util.concurrent.CompletableFuture<java.lang.Object[]> exec​(@NonNull
                                                                               @NonNull Batch batch,
                                                                               boolean raiseOnError)
        Description copied from interface: TransactionsCommands
        Executes a batch by processing the queued commands.

        Notes:

        • Atomic Batches - Transactions: If the transaction fails due to a WATCH command, EXEC will return null.
        Specified by:
        exec in interface TransactionsCommands
        Parameters:
        batch - A Batch containing the commands to execute.
        raiseOnError - Determines how errors are handled within the batch response.

        When set to true, the first encountered error in the batch will be raised as an exception of type RequestException after all retries and reconnections have been executed.

        When set to false, errors will be included as part of the batch response, allowing the caller to process both successful and failed commands together. In this case, error details will be provided as instances of RequestException.

        Returns:
        A CompletableFuture resolving to an array of results, where each entry corresponds to a command’s execution result.
        See Also:
        Valkey Transactions (Atomic Batches), Valkey Pipelines (Non-Atomic Batches)
      • exec

        public java.util.concurrent.CompletableFuture<java.lang.Object[]> exec​(@NonNull
                                                                               @NonNull Batch batch,
                                                                               boolean raiseOnError,
                                                                               @NonNull
                                                                               @NonNull BatchOptions options)
        Description copied from interface: TransactionsCommands
        Executes a batch by processing the queued commands with additional options.

        Notes:

        • Atomic Batches - Transactions: If the transaction fails due to a WATCH command, EXEC will return null.
        Specified by:
        exec in interface TransactionsCommands
        Parameters:
        batch - A Batch containing the commands to execute.
        raiseOnError - Determines how errors are handled within the batch response.

        When set to true, the first encountered error in the batch will be raised as an exception of type RequestException after all retries and reconnections have been executed.

        When set to false, errors will be included as part of the batch response, allowing the caller to process both successful and failed commands together. In this case, error details will be provided as instances of RequestException.

        options - A BatchOptions object containing execution options.
        Returns:
        A CompletableFuture resolving to an array of results, where each entry corresponds to a command’s execution result.
        See Also:
        Valkey Transactions (Atomic Batches), Valkey Pipelines (Non-Atomic Batches)
      • ping

        public java.util.concurrent.CompletableFuture<java.lang.String> ping​(@NonNull
                                                                             @NonNull java.lang.String message)
        Description copied from interface: ConnectionManagementCommands
        Pings the server.
        Specified by:
        ping in interface ConnectionManagementCommands
        Parameters:
        message - The server will respond with a copy of the message.
        Returns:
        String with a copy of the argument message.
        See Also:
        valkey.io for details.
      • info

        public java.util.concurrent.CompletableFuture<java.lang.String> info​(@NonNull
                                                                             @NonNull InfoOptions.Section[] sections)
        Description copied from interface: ServerManagementCommands
        Get information and statistics about the server.
        Starting from server version 7, command supports multiple section arguments.
        Specified by:
        info in interface ServerManagementCommands
        Parameters:
        sections - A list of InfoOptions.Section values specifying which sections of information to retrieve. When no parameter is provided, the InfoOptions.Section.DEFAULT option is assumed.
        Returns:
        A String containing the information for the sections requested.
        See Also:
        valkey.io for details.
      • select

        public java.util.concurrent.CompletableFuture<java.lang.String> select​(long index)
        Description copied from interface: ConnectionManagementCommands
        Changes the currently selected database.

        WARNING: This command is NOT RECOMMENDED for production use. Upon reconnection, the client will revert to the database_id specified in the client configuration (default: 0), NOT the database selected via this command.

        RECOMMENDED APPROACH: Use the database_id parameter in client configuration instead:

        RECOMMENDED EXAMPLE:

        
         GlideClient client = GlideClient.createClient(
             GlideClientConfiguration.builder()
                 .address(NodeAddress.builder().host("localhost").port(6379).build())
                 .databaseId(5)  // Recommended: persists across reconnections
                 .build()
         ).get();
         
        Specified by:
        select in interface ConnectionManagementCommands
        Parameters:
        index - The index of the database to select.
        Returns:
        A simple OK response.
        See Also:
        valkey.io for details.
      • clientPause

        public java.util.concurrent.CompletableFuture<java.lang.String> clientPause​(long timeout)
        Description copied from interface: ConnectionManagementCommands
        Suspends all clients for the specified timeout.
        Specified by:
        clientPause in interface ConnectionManagementCommands
        Parameters:
        timeout - The time in milliseconds to suspend clients.
        Returns:
        "OK" response on success.
        See Also:
        valkey.io for details.
      • clientPause

        public java.util.concurrent.CompletableFuture<java.lang.String> clientPause​(long timeout,
                                                                                    @NonNull
                                                                                    @NonNull ClientPauseMode mode)
        Description copied from interface: ConnectionManagementCommands
        Suspends all clients for the specified timeout.
        Specified by:
        clientPause in interface ConnectionManagementCommands
        Parameters:
        timeout - The time in milliseconds to pause clients.
        mode - The pause mode to use.
        Returns:
        "OK" response on success.
        See Also:
        valkey.io for details.
      • clientGetName

        public java.util.concurrent.CompletableFuture<java.lang.String> clientGetName()
        Description copied from interface: ConnectionManagementCommands
        Gets the name of the current connection.
        Specified by:
        clientGetName in interface ConnectionManagementCommands
        Returns:
        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.
      • clientTrackingInfo

        public java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,​java.lang.Object>> clientTrackingInfo()
        Description copied from interface: ConnectionManagementCommands
        Returns information about the current client connection's use of the server assisted client side caching feature.
        Specified by:
        clientTrackingInfo in interface ConnectionManagementCommands
        Returns:
        A Map with the client's tracking state. The map contains:
        • flags: a Set of tracking flags. See valkey.io for the full list.
        • redirect: a Long with the client ID receiving invalidation messages, or -1 if not redirecting
        • prefixes: an Object[] of key prefixes monitored for invalidation
        See Also:
        valkey.io for details.
      • configRewrite

        public java.util.concurrent.CompletableFuture<java.lang.String> configRewrite()
        Description copied from interface: ServerManagementCommands
        Rewrites the configuration file with the current configuration.
        Specified by:
        configRewrite in interface ServerManagementCommands
        Returns:
        "OK" response on success.
        See Also:
        valkey.io for details.
      • configGet

        public java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,​java.lang.String>> configGet​(@NonNull
                                                                                                                        @NonNull java.lang.String[] parameters)
        Description copied from interface: ServerManagementCommands
        Get the values of configuration parameters.
        Starting from server version 7, command supports multiple parameters.
        Specified by:
        configGet in interface ServerManagementCommands
        Parameters:
        parameters - An array of configuration parameter names to retrieve values for.
        Returns:
        A map of values corresponding to the configuration parameters.
        See Also:
        valkey.io for details.
      • configSet

        public java.util.concurrent.CompletableFuture<java.lang.String> configSet​(@NonNull
                                                                                  @NonNull java.util.Map<java.lang.String,​java.lang.String> parameters)
        Description copied from interface: ServerManagementCommands
        Sets configuration parameters to the specified values.
        Starting from server version 7, command supports multiple parameters.
        Specified by:
        configSet in interface ServerManagementCommands
        Parameters:
        parameters - A map consisting of configuration parameters and their respective values to set.
        Returns:
        "OK" response on success.
        See Also:
        valkey.io for details.
      • echo

        public java.util.concurrent.CompletableFuture<java.lang.String> echo​(@NonNull
                                                                             @NonNull java.lang.String message)
        Description copied from interface: ConnectionManagementCommands
        Echoes the provided message back.
        Specified by:
        echo in interface ConnectionManagementCommands
        Parameters:
        message - The message to be echoed back.
        Returns:
        The provided message.
        See Also:
        valkey.io for details.
      • time

        public java.util.concurrent.CompletableFuture<java.lang.String[]> time()
        Description copied from interface: ServerManagementCommands
        Returns the server time.
        Specified by:
        time in interface ServerManagementCommands
        Returns:
        The current server time as a String array with two elements: A UNIX TIME and the amount of microseconds already elapsed in the current second. The returned array is in a [UNIX TIME, Microseconds already elapsed] format.
        See Also:
        valkey.io for details.
      • lastsave

        public java.util.concurrent.CompletableFuture<java.lang.Long> lastsave()
        Description copied from interface: ServerManagementCommands
        Returns UNIX TIME of the last DB save timestamp or startup timestamp if no save was made since then.
        Specified by:
        lastsave in interface ServerManagementCommands
        Returns:
        UNIX TIME of the last DB save executed with success.
        See Also:
        valkey.io for details.
      • save

        public java.util.concurrent.CompletableFuture<java.lang.String> save()
        Description copied from interface: ServerManagementCommands
        Synchronously saves the dataset to disk.
        Specified by:
        save in interface ServerManagementCommands
        Returns:
        "OK" response on success.
        See Also:
        valkey.io for details.
      • bgsave

        public java.util.concurrent.CompletableFuture<java.lang.String> bgsave()
        Description copied from interface: ServerManagementCommands
        Asynchronously saves the dataset to disk in the background.
        Specified by:
        bgsave in interface ServerManagementCommands
        Returns:
        A non-empty status string.
        See Also:
        valkey.io for details.
      • bgsaveCancel

        public java.util.concurrent.CompletableFuture<java.lang.String> bgsaveCancel()
        Description copied from interface: ServerManagementCommands
        Aborts all in-progress and scheduled background saves.
        Specified by:
        bgsaveCancel in interface ServerManagementCommands
        Returns:
        A non-empty status string.
        See Also:
        valkey.io for details.
      • bgrewriteaof

        public java.util.concurrent.CompletableFuture<java.lang.String> bgrewriteaof()
        Description copied from interface: ServerManagementCommands
        Initiates a background rewrite of the append-only file (AOF).
        Specified by:
        bgrewriteaof in interface ServerManagementCommands
        Returns:
        A non-empty status string.
        See Also:
        valkey.io for details.
      • flushall

        public java.util.concurrent.CompletableFuture<java.lang.String> flushall()
        Description copied from interface: ServerManagementCommands
        Deletes all the keys of all the existing databases. This command never fails.
        Specified by:
        flushall in interface ServerManagementCommands
        Returns:
        "OK" response on success.
        See Also:
        valkey.io for details.
      • flushdb

        public java.util.concurrent.CompletableFuture<java.lang.String> flushdb()
        Description copied from interface: ServerManagementCommands
        Deletes all the keys of the currently selected database. This command never fails.
        Specified by:
        flushdb in interface ServerManagementCommands
        Returns:
        "OK" response on success.
        See Also:
        valkey.io for details.
      • lolwut

        public java.util.concurrent.CompletableFuture<java.lang.String> lolwut()
        Description copied from interface: ServerManagementCommands
        Displays a piece of generative computer art and the Valkey version.
        Specified by:
        lolwut in interface ServerManagementCommands
        Returns:
        A piece of generative computer art along with the current Valkey version.
        See Also:
        valkey.io for details.
      • lolwut

        public java.util.concurrent.CompletableFuture<java.lang.String> lolwut​(int @NonNull [] parameters)
        Description copied from interface: ServerManagementCommands
        Displays a piece of generative computer art and the Valkey version.
        Specified by:
        lolwut in interface ServerManagementCommands
        Parameters:
        parameters - Additional set of arguments in order to change the output:
        • On Valkey version 5, those are length of the line, number of squares per row, and number of squares per column.
        • On Valkey version 6, those are number of columns and number of lines.
        • On other versions parameters are ignored.
        Returns:
        A piece of generative computer art along with the current Valkey version.
        See Also:
        valkey.io for details.
      • lolwut

        public java.util.concurrent.CompletableFuture<java.lang.String> lolwut​(int version)
        Description copied from interface: ServerManagementCommands
        Displays a piece of generative computer art and the Valkey version.
        Specified by:
        lolwut in interface ServerManagementCommands
        Parameters:
        version - Version of computer art to generate.
        Returns:
        A piece of generative computer art along with the current Valkey version.
        See Also:
        valkey.io for details.
      • lolwut

        public java.util.concurrent.CompletableFuture<java.lang.String> lolwut​(int version,
                                                                               int @NonNull [] parameters)
        Description copied from interface: ServerManagementCommands
        Displays a piece of generative computer art and the Valkey version.
        Specified by:
        lolwut in interface ServerManagementCommands
        Parameters:
        version - Version of computer art to generate.
        parameters - Additional set of arguments in order to change the output:
        • For version 5, those are length of the line, number of squares per row, and number of squares per column.
        • For version 6, those are number of columns and number of lines.
        Returns:
        A piece of generative computer art along with the current Valkey version.
        See Also:
        valkey.io for details.
      • dbsize

        public java.util.concurrent.CompletableFuture<java.lang.Long> dbsize()
        Description copied from interface: ServerManagementCommands
        Returns the number of keys in the currently selected database.
        Specified by:
        dbsize in interface ServerManagementCommands
        Returns:
        The number of keys in the currently selected database.
        See Also:
        valkey.io for details.
      • replicaof

        public java.util.concurrent.CompletableFuture<java.lang.String> replicaof​(@NonNull
                                                                                  @NonNull java.lang.String host,
                                                                                  int port)
        Description copied from interface: ServerManagementCommands
        Makes the server a replica of the specified primary.
        Specified by:
        replicaof in interface ServerManagementCommands
        Parameters:
        host - The host of the primary to replicate.
        port - The port of the primary to replicate.
        Returns:
        OK on success.
        See Also:
        valkey.io for details.
      • latencyHistory

        public java.util.concurrent.CompletableFuture<java.lang.Object[][]> latencyHistory​(@NonNull
                                                                                           @NonNull java.lang.String event)
        Description copied from interface: ServerManagementCommands
        Returns the latency spike time series for the specified event.
        Specified by:
        latencyHistory in interface ServerManagementCommands
        Parameters:
        event - The name of the latency event (e.g., "command").
        Returns:
        An array of arrays representing latency spike entries, or an empty array if the event doesn't exist.
        See Also:
        valkey.io for details.
      • latencyLatest

        public java.util.concurrent.CompletableFuture<java.lang.Object[][]> latencyLatest()
        Description copied from interface: ServerManagementCommands
        Reports the latest latency events logged by the server.
        Specified by:
        latencyLatest in interface ServerManagementCommands
        Returns:
        An array of arrays representing latency event info.
        See Also:
        valkey.io for details.
      • latencyReset

        public java.util.concurrent.CompletableFuture<java.lang.Long> latencyReset()
        Description copied from interface: ServerManagementCommands
        Resets the latency spike time series for all events.
        Specified by:
        latencyReset in interface ServerManagementCommands
        Returns:
        The number of event time series that were reset.
        See Also:
        valkey.io for details.
      • latencyReset

        public java.util.concurrent.CompletableFuture<java.lang.Long> latencyReset​(@NonNull
                                                                                   @NonNull java.lang.String[] events)
        Description copied from interface: ServerManagementCommands
        Resets the latency spike time series for the specified events.
        If events is empty, resets the latency spike time series for all events.
        Specified by:
        latencyReset in interface ServerManagementCommands
        Parameters:
        events - The event names to reset.
        Returns:
        The number of event time series that were reset.
        See Also:
        valkey.io for details.
      • functionLoad

        public java.util.concurrent.CompletableFuture<java.lang.String> functionLoad​(@NonNull
                                                                                     @NonNull java.lang.String libraryCode,
                                                                                     boolean replace)
        Description copied from interface: ScriptingAndFunctionsCommands
        Loads a library to Valkey.
        Specified by:
        functionLoad in interface ScriptingAndFunctionsCommands
        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.
        See Also:
        valkey.io for details.
      • functionLoad

        public java.util.concurrent.CompletableFuture<GlideString> functionLoad​(@NonNull
                                                                                @NonNull GlideString libraryCode,
                                                                                boolean replace)
        Description copied from interface: ScriptingAndFunctionsCommands
        Loads a library to Valkey.
        Specified by:
        functionLoad in interface ScriptingAndFunctionsCommands
        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.
        See Also:
        valkey.io for details.
      • functionList

        public java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,​java.lang.Object>[]> functionList​(boolean withCode)
        Description copied from interface: ScriptingAndFunctionsCommands
        Returns information about the functions and libraries.
        Specified by:
        functionList in interface ScriptingAndFunctionsCommands
        Parameters:
        withCode - Specifies whether to request the library code from the server or not.
        Returns:
        Info about all libraries and their functions.
        See Also:
        valkey.io for details.
      • functionListBinary

        public java.util.concurrent.CompletableFuture<java.util.Map<GlideString,​java.lang.Object>[]> functionListBinary​(boolean withCode)
        Description copied from interface: ScriptingAndFunctionsCommands
        Returns information about the functions and libraries.
        Specified by:
        functionListBinary in interface ScriptingAndFunctionsCommands
        Parameters:
        withCode - Specifies whether to request the library code from the server or not.
        Returns:
        Info about all libraries and their functions.
        See Also:
        valkey.io for details.
      • functionList

        public java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,​java.lang.Object>[]> functionList​(@NonNull
                                                                                                                             @NonNull java.lang.String libNamePattern,
                                                                                                                             boolean withCode)
        Description copied from interface: ScriptingAndFunctionsCommands
        Returns information about the functions and libraries.
        Specified by:
        functionList in interface ScriptingAndFunctionsCommands
        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.
        See Also:
        valkey.io for details.
      • functionListBinary

        public java.util.concurrent.CompletableFuture<java.util.Map<GlideString,​java.lang.Object>[]> functionListBinary​(@NonNull
                                                                                                                              @NonNull GlideString libNamePattern,
                                                                                                                              boolean withCode)
        Description copied from interface: ScriptingAndFunctionsCommands
        Returns information about the functions and libraries.
        Specified by:
        functionListBinary in interface ScriptingAndFunctionsCommands
        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.
        See Also:
        valkey.io for details.
      • functionDelete

        public java.util.concurrent.CompletableFuture<java.lang.String> functionDelete​(@NonNull
                                                                                       @NonNull java.lang.String libName)
        Description copied from interface: ScriptingAndFunctionsCommands
        Deletes a library and all its functions.
        Specified by:
        functionDelete in interface ScriptingAndFunctionsCommands
        Parameters:
        libName - The library name to delete.
        Returns:
        OK.
        See Also:
        valkey.io for details.
      • fcallReadOnly

        public java.util.concurrent.CompletableFuture<java.lang.Object> fcallReadOnly​(@NonNull
                                                                                      @NonNull java.lang.String function)
        Description copied from interface: ScriptingAndFunctionsCommands
        Invokes a previously loaded read-only function.
        This command is routed depending on the client's ReadFrom strategy.
        Specified by:
        fcallReadOnly in interface ScriptingAndFunctionsCommands
        Parameters:
        function - The function name.
        Returns:
        The invoked function's return value.
        See Also:
        valkey.io for details.
      • fcallReadOnly

        public java.util.concurrent.CompletableFuture<java.lang.Object> fcallReadOnly​(@NonNull
                                                                                      @NonNull GlideString function)
        Description copied from interface: ScriptingAndFunctionsCommands
        Invokes a previously loaded read-only function.
        This command is routed depending on the client's ReadFrom strategy.
        Specified by:
        fcallReadOnly in interface ScriptingAndFunctionsCommands
        Parameters:
        function - The function name.
        Returns:
        The invoked function's return value.
        See Also:
        valkey.io for details.
      • functionKill

        public java.util.concurrent.CompletableFuture<java.lang.String> functionKill()
        Description copied from interface: ScriptingAndFunctionsCommands
        Kills a function that is currently executing.
        FUNCTION KILL terminates read-only functions only. FUNCTION KILL runs on all nodes of the server, including primary and replicas.
        Specified by:
        functionKill in interface ScriptingAndFunctionsCommands
        Returns:
        OK if function is terminated. Otherwise, throws an error.
        See Also:
        valkey.io for details.
      • functionStats

        public java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,​java.util.Map<java.lang.String,​java.util.Map<java.lang.String,​java.lang.Object>>>> functionStats()
        Description copied from interface: ScriptingAndFunctionsCommands
        Returns information about the function that's currently running and information about the available execution engines.
        FUNCTION STATS runs on all nodes of the server, including primary and replicas. The response includes a mapping from node address to the command response for that node.
        Specified by:
        functionStats in interface ScriptingAndFunctionsCommands
        Returns:
        A Map from node address to the command response for that node, where the command contains a Map with two keys:
        • running_script with information about the running script.
        • engines with information about available engines and their stats.
        See example for more details.
        See Also:
        valkey.io for details.
      • functionStatsBinary

        public java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,​java.util.Map<GlideString,​java.util.Map<GlideString,​java.lang.Object>>>> functionStatsBinary()
        Description copied from interface: ScriptingAndFunctionsCommands
        Returns information about the function that's currently running and information about the available execution engines.
        FUNCTION STATS runs on all nodes of the server, including primary and replicas. The response includes a mapping from node address to the command response for that node.
        Specified by:
        functionStatsBinary in interface ScriptingAndFunctionsCommands
        Returns:
        A Map from node address to the command response for that node, where the command contains a Map with two keys:
        • running_script with information about the running script.
        • engines with information about available engines and their stats.
        See example for more details.
        See Also:
        valkey.io for details.
      • unwatch

        public java.util.concurrent.CompletableFuture<java.lang.String> unwatch()
        Description copied from interface: TransactionsCommands
        Flushes all the previously watched keys for a transaction. Executing a transaction will automatically flush all previously watched keys.
        Specified by:
        unwatch in interface TransactionsCommands
        Returns:
        OK.
        See Also:
        valkey.io for details.
      • randomKey

        public java.util.concurrent.CompletableFuture<java.lang.String> randomKey()
        Description copied from interface: GenericCommands
        Returns a random key from currently selected database.
        Specified by:
        randomKey in interface GenericCommands
        Returns:
        A random key from the database.
        See Also:
        valkey.io for details.
      • randomKeyBinary

        public java.util.concurrent.CompletableFuture<GlideString> randomKeyBinary()
        Description copied from interface: GenericCommands
        Returns a random key from currently selected database.
        Specified by:
        randomKeyBinary in interface GenericCommands
        Returns:
        A random key from the database.
        See Also:
        valkey.io for details.
      • keys

        public java.util.concurrent.CompletableFuture<java.lang.String[]> keys​(java.lang.String pattern)
        Returns all keys matching pattern.
        Parameters:
        pattern - The pattern to match keys against.
        Returns:
        An array of keys matching the pattern. If no keys match, returns an empty array.
        See Also:
        valkey.io for details.
        Example:
        
         String[] keys = client.keys("key*").get();
         System.out.println("Found keys: " + Arrays.toString(keys));
         
      • keys

        public java.util.concurrent.CompletableFuture<GlideString[]> keys​(GlideString pattern)
        Returns all keys matching pattern.
        Parameters:
        pattern - The pattern to match keys against.
        Returns:
        An array of keys matching the pattern. If no keys match, returns an empty array.
        See Also:
        valkey.io for details.
        Example:
        
         GlideString[] keys = client.keys(gs("key*")).get();
         System.out.println("Found keys: " + Arrays.toString(keys));
         
      • scan

        public java.util.concurrent.CompletableFuture<java.lang.Object[]> scan​(@NonNull
                                                                               @NonNull java.lang.String cursor)
        Description copied from interface: GenericCommands
        Iterates incrementally over a database for matching keys.
        Specified by:
        scan in interface GenericCommands
        Parameters:
        cursor - The cursor that points to the next iteration of results. A value of "0" indicates the start of the search.
        Returns:
        An Array of Objects. The first element is always the cursor for the next iteration of results. "0" will be the cursor returned on the last iteration of the scan.
        The second element is always an Array of matched keys from the database.
        See Also:
        valkey.io for details.
      • scan

        public java.util.concurrent.CompletableFuture<java.lang.Object[]> scan​(@NonNull
                                                                               @NonNull GlideString cursor)
        Description copied from interface: GenericCommands
        Iterates incrementally over a database for matching keys.
        Specified by:
        scan in interface GenericCommands
        Parameters:
        cursor - The cursor that points to the next iteration of results. A value of gs("0") indicates the start of the search.
        Returns:
        An Array of Objects. The first element is always the cursor for the next iteration of results. gs("0") will be the cursor returned on the last iteration of the scan.
        The second element is always an Array of matched keys from the database.
        See Also:
        valkey.io for details.
      • scan

        public java.util.concurrent.CompletableFuture<java.lang.Object[]> scan​(@NonNull
                                                                               @NonNull java.lang.String cursor,
                                                                               @NonNull
                                                                               @NonNull ScanOptions options)
        Description copied from interface: GenericCommands
        Iterates incrementally over a database for matching keys.
        Specified by:
        scan in interface GenericCommands
        Parameters:
        cursor - The cursor that points to the next iteration of results. A value of "0" indicates the start of the search.
        options - The ScanOptions.
        Returns:
        An Array of Objects. The first element is always the cursor for the next iteration of results. "0" will be the cursor returned on the last iteration of the scan.
        The second element is always an Array of matched keys from the database.
        See Also:
        valkey.io for details.
      • scan

        public java.util.concurrent.CompletableFuture<java.lang.Object[]> scan​(@NonNull
                                                                               @NonNull GlideString cursor,
                                                                               @NonNull
                                                                               @NonNull ScanOptions options)
        Description copied from interface: GenericCommands
        Iterates incrementally over a database for matching keys.
        Specified by:
        scan in interface GenericCommands
        Parameters:
        cursor - The cursor that points to the next iteration of results. A value of gs("0") indicates the start of the search.
        options - The ScanOptions.
        Returns:
        An Array of Objects. The first element is always the cursor for the next iteration of results. gs("0") will be the cursor returned on the last iteration of the scan.
        The second element is always an Array of matched keys from the database.
        See Also:
        valkey.io for details.
      • getSubscriptions

        public java.util.concurrent.CompletableFuture<PubSubState<StandaloneSubscriptionConfiguration.PubSubChannelMode>> getSubscriptions()
        Gets the current subscription state for this client.

        Returns the desired and actual subscription states, which may differ if subscriptions are being reconciled after a connection loss.

        The returned PubSubState contains:

        • Desired subscriptions: The channels/patterns the client intends to be subscribed to
        • Actual subscriptions: The channels/patterns currently subscribed on the server
        Returns:
        A CompletableFuture that completes with a PubSubState containing:
        • EXACT - Set of exact channel names
        • PATTERN - Set of pattern subscriptions
        See Also:
        valkey.io for PUBSUB CHANNELS, valkey.io for PUBSUB NUMPAT
        Example:
        
         // Get current subscription state
         PubSubState<PubSubChannelMode> state = client.getSubscriptions().get();
        
         // Check desired subscriptions
         Set<String> desiredChannels = state.getDesiredSubscriptions()
             .getOrDefault(PubSubChannelMode.EXACT, Set.of());
         System.out.println("Desired channels: " + desiredChannels);
        
         // Check actual subscriptions
         Set<String> actualChannels = state.getActualSubscriptions()
             .getOrDefault(PubSubChannelMode.EXACT, Set.of());
         System.out.println("Actual channels: " + actualChannels);
         
      • migrate

        public java.util.concurrent.CompletableFuture<java.lang.String> migrate​(java.lang.String destinationHost,
                                                                                long destinationPort,
                                                                                java.lang.String[] keys,
                                                                                long destinationDB,
                                                                                long timeout)
        Description copied from interface: GenericCommands
        Migrate multiple keys from the current server to a destination server. This command is for standalone clients only (not cluster mode).
        Specified by:
        migrate in interface GenericCommands
        Parameters:
        destinationHost - Hostname or IP address of the destination server.
        destinationPort - Port of the destination server.
        keys - The keys to migrate. Must not be null or empty.
        destinationDB - The database index on the destination server.
        timeout - Maximum idle time in milliseconds for the bulk-transfer.
        Returns:
        "OK" on success.
        See Also:
        valkey.io for details.
      • migrate

        public java.util.concurrent.CompletableFuture<java.lang.String> migrate​(java.lang.String destinationHost,
                                                                                long destinationPort,
                                                                                java.lang.String[] keys,
                                                                                long destinationDB,
                                                                                long timeout,
                                                                                @NonNull
                                                                                @NonNull MigrateOptions migrateOptions)
        Description copied from interface: GenericCommands
        Migrate multiple keys from the current server to a destination server with options.
        Specified by:
        migrate in interface GenericCommands
        Parameters:
        destinationHost - Hostname or IP address of the destination server.
        destinationPort - Port of the destination server.
        keys - The keys to migrate. Must not be null or empty.
        destinationDB - The database index on the destination server.
        timeout - Maximum idle time in milliseconds for the bulk-transfer.
        migrateOptions - Additional options.
        Returns:
        "OK" on success.
        See Also:
        valkey.io for details.
      • memoryDoctor

        public java.util.concurrent.CompletableFuture<java.lang.String> memoryDoctor()
        Description copied from interface: ServerManagementCommands
        Returns a report about memory problems detected by the server.
        Specified by:
        memoryDoctor in interface ServerManagementCommands
        Returns:
        The memory diagnostic report.
        See Also:
        valkey.io for details.
      • memoryMallocStats

        public java.util.concurrent.CompletableFuture<java.lang.String> memoryMallocStats()
        Description copied from interface: ServerManagementCommands
        Returns the internal statistics of the memory allocator.
        Specified by:
        memoryMallocStats in interface ServerManagementCommands
        Returns:
        The memory allocator statistics.
        See Also:
        valkey.io for details.
      • memoryPurge

        public java.util.concurrent.CompletableFuture<java.lang.String> memoryPurge()
        Description copied from interface: ServerManagementCommands
        Asks the server to reclaim memory from the allocator back to the operating system.
        Specified by:
        memoryPurge in interface ServerManagementCommands
        Returns:
        "OK" response on success.
        See Also:
        valkey.io for details.
      • memoryStats

        public java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,​java.lang.Object>> memoryStats()
        Description copied from interface: ServerManagementCommands
        Returns detailed memory consumption statistics of the server.
        Specified by:
        memoryStats in interface ServerManagementCommands
        Returns:
        A Map of memory statistics.
        See Also:
        valkey.io for details.