Interface ServerManagementCommands

  • All Known Implementing Classes:
    GlideClient

    public interface ServerManagementCommands
    Supports commands for the "Server Management" group for a standalone client.
    See Also:
    Server Management Commands
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,​java.lang.String>> configGet​(java.lang.String[] parameters)
      Get the values of configuration parameters.
      Starting from server version 7, command supports multiple parameters.
      java.util.concurrent.CompletableFuture<java.lang.String> configResetStat()
      Resets the statistics reported by the server using the INFO and LATENCY HISTOGRAM commands.
      java.util.concurrent.CompletableFuture<java.lang.String> configRewrite()
      Rewrites the configuration file with the current configuration.
      java.util.concurrent.CompletableFuture<java.lang.String> configSet​(java.util.Map<java.lang.String,​java.lang.String> parameters)
      Sets configuration parameters to the specified values.
      Starting from server version 7, command supports multiple parameters.
      java.util.concurrent.CompletableFuture<java.lang.Long> dbsize()
      Returns the number of keys in the currently selected database.
      java.util.concurrent.CompletableFuture<java.lang.String> flushall()
      Deletes all the keys of all the existing databases.
      java.util.concurrent.CompletableFuture<java.lang.String> flushall​(FlushMode mode)
      Deletes all the keys of all the existing databases.
      java.util.concurrent.CompletableFuture<java.lang.String> flushdb()
      Deletes all the keys of the currently selected database.
      java.util.concurrent.CompletableFuture<java.lang.String> flushdb​(FlushMode mode)
      Deletes all the keys of the currently selected database.
      java.util.concurrent.CompletableFuture<java.lang.String> info()
      Gets information and statistics about the server using the InfoOptions.Section.DEFAULT option.
      java.util.concurrent.CompletableFuture<java.lang.String> info​(InfoOptions.Section[] sections)
      Get information and statistics about the server.
      Starting from server version 7, command supports multiple section arguments.
      java.util.concurrent.CompletableFuture<java.lang.Long> lastsave()
      Returns UNIX TIME of the last DB save timestamp or startup timestamp if no save was made since then.
      java.util.concurrent.CompletableFuture<java.lang.String> lolwut()
      Displays a piece of generative computer art and the Valkey version.
      java.util.concurrent.CompletableFuture<java.lang.String> lolwut​(int version)
      Displays a piece of generative computer art and the Valkey version.
      java.util.concurrent.CompletableFuture<java.lang.String> lolwut​(int[] parameters)
      Displays a piece of generative computer art and the Valkey version.
      java.util.concurrent.CompletableFuture<java.lang.String> lolwut​(int version, int[] parameters)
      Displays a piece of generative computer art and the Valkey version.
      java.util.concurrent.CompletableFuture<java.lang.String[]> time()
      Returns the server time.
    • Method Detail

      • info

        java.util.concurrent.CompletableFuture<java.lang.String> info()
        Gets information and statistics about the server using the InfoOptions.Section.DEFAULT option.
        Returns:
        A String with the information for the default sections.
        See Also:
        valkey.io for details.
        Example:
        
         String response = client.info().get();
         assert response.contains("# Stats");
         
      • info

        java.util.concurrent.CompletableFuture<java.lang.String> info​(InfoOptions.Section[] sections)
        Get information and statistics about the server.
        Starting from server version 7, command supports multiple section arguments.
        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.
        Example:
        
         String response = regularClient.info(new Section[] { Section.STATS }).get();
         assert response.contains("total_net_input_bytes");
         
      • configRewrite

        java.util.concurrent.CompletableFuture<java.lang.String> configRewrite()
        Rewrites the configuration file with the current configuration.
        Returns:
        OK when the configuration was rewritten properly, otherwise an error is thrown.
        See Also:
        valkey.io for details.
        Example:
        
         String response = client.configRewrite().get();
         assert response.equals("OK");
         
      • configResetStat

        java.util.concurrent.CompletableFuture<java.lang.String> configResetStat()
        Resets the statistics reported by the server using the INFO and LATENCY HISTOGRAM commands.
        Returns:
        OK to confirm that the statistics were successfully reset.
        See Also:
        valkey.io for details.
        Example:
        
         String response = client.configResetStat().get();
         assert response.equals("OK");
         
      • configGet

        java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,​java.lang.String>> configGet​(java.lang.String[] parameters)
        Get the values of configuration parameters.
        Starting from server version 7, command supports multiple parameters.
        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.
        Example:
        
         Map<String, String> configParams = client.configGet(new String[] {"timeout" , "maxmemory"}).get();
         assert configParams.get("timeout").equals("1000");
         assert configParams.get("maxmemory").equals("1GB");
         
      • configSet

        java.util.concurrent.CompletableFuture<java.lang.String> configSet​(java.util.Map<java.lang.String,​java.lang.String> parameters)
        Sets configuration parameters to the specified values.
        Starting from server version 7, command supports multiple parameters.
        Parameters:
        parameters - A map consisting of configuration parameters and their respective values to set.
        Returns:
        OK if all configurations have been successfully set. Otherwise, raises an error.
        See Also:
        valkey.io for details.
        Example:
        
         String response = client.configSet(Map.of("timeout", "1000", "maxmemory", "1GB")).get();
         assert response.equals("OK");
         
      • time

        java.util.concurrent.CompletableFuture<java.lang.String[]> time()
        Returns the server time.
        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.
        Example:
        
         String[] serverTime = client.time().get();
         System.out.println("Server time is: " + serverTime[0] + "." + serverTime[1]);
         
      • lastsave

        java.util.concurrent.CompletableFuture<java.lang.Long> lastsave()
        Returns UNIX TIME of the last DB save timestamp or startup timestamp if no save was made since then.
        Returns:
        UNIX TIME of the last DB save executed with success.
        See Also:
        valkey.io for details.
        Example:
        
         Long timestamp = client.lastsave().get();
         System.out.printf("Last DB save was done at %s%n", Instant.ofEpochSecond(timestamp));
         
      • flushall

        java.util.concurrent.CompletableFuture<java.lang.String> flushall()
        Deletes all the keys of all the existing databases. This command never fails.
        Returns:
        OK.
        See Also:
        valkey.io for details.
        Example:
        
         String response = client.flushall().get();
         assert response.equals("OK");
         
      • flushall

        java.util.concurrent.CompletableFuture<java.lang.String> flushall​(FlushMode mode)
        Deletes all the keys of all the existing databases. This command never fails.
        Parameters:
        mode - The flushing mode, could be either FlushMode.SYNC or FlushMode.ASYNC.
        Returns:
        OK.
        See Also:
        valkey.io for details.
        Example:
        
         String response = client.flushall(ASYNC).get();
         assert response.equals("OK");
         
      • flushdb

        java.util.concurrent.CompletableFuture<java.lang.String> flushdb()
        Deletes all the keys of the currently selected database. This command never fails.
        Returns:
        OK.
        See Also:
        valkey.io for details.
        Example:
        
         String response = client.flushdb().get();
         assert response.equals("OK");
         
      • flushdb

        java.util.concurrent.CompletableFuture<java.lang.String> flushdb​(FlushMode mode)
        Deletes all the keys of the currently selected database. This command never fails.
        Parameters:
        mode - The flushing mode, could be either FlushMode.SYNC or FlushMode.ASYNC.
        Returns:
        OK.
        See Also:
        valkey.io for details.
        Example:
        
         String response = client.flushdb(ASYNC).get();
         assert response.equals("OK");
         
      • lolwut

        java.util.concurrent.CompletableFuture<java.lang.String> lolwut()
        Displays a piece of generative computer art and the Valkey version.
        Returns:
        A piece of generative computer art along with the current Valkey version.
        See Also:
        valkey.io for details.
        Example:
        
         String data = client.lolwut().get();
         System.out.println(data);
         assert data.contains("Redis ver. 7.2.3");
         
      • lolwut

        java.util.concurrent.CompletableFuture<java.lang.String> lolwut​(int[] parameters)
        Displays a piece of generative computer art and the Valkey version.
        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.
        Example:
        
         String data = client.lolwut(new int[] { 40, 20 }).get();
         System.out.println(data);
         assert data.contains("Redis ver. 7.2.3");
         
      • lolwut

        java.util.concurrent.CompletableFuture<java.lang.String> lolwut​(int version)
        Displays a piece of generative computer art and the Valkey version.
        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.
        Example:
        
         String data = client.lolwut(6).get();
         System.out.println(data);
         assert data.contains("Redis ver. 7.2.3");
         
      • lolwut

        java.util.concurrent.CompletableFuture<java.lang.String> lolwut​(int version,
                                                                        int[] parameters)
        Displays a piece of generative computer art and the Valkey version.
        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.
        Example:
        
         String data = client.lolwut(6, new int[] { 40, 20 }).get();
         System.out.println(data);
         assert data.contains("Redis ver. 7.2.3");
         data = client.lolwut(5, new int[] { 30, 5, 5 }).get();
         System.out.println(data);
         assert data.contains("Redis ver. 7.2.3");
         
      • dbsize

        java.util.concurrent.CompletableFuture<java.lang.Long> dbsize()
        Returns the number of keys in the currently selected database.
        Returns:
        The number of keys in the currently selected database.
        See Also:
        valkey.io for details.
        Example:
        
         Long numKeys = client.dbsize().get();
         System.out.printf("Number of keys in the current database: %d%n", numKeys);