Interface StringBaseCommands

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String IDX_COMMAND_STRING
      IDX option string to include in the LCS command.
      static java.lang.String LCS_MATCHES_RESULT_KEY
      Key for LCS matches result.
      static java.lang.String LEN_VALKEY_API
      Valkey API keyword used to indicate that the length of the lcs should be returned.
      static java.lang.String MINMATCHLEN_COMMAND_STRING
      MINMATCHLEN option string to include in the LCS command.
      static java.lang.String WITHMATCHLEN_COMMAND_STRING
      WITHMATCHLEN option string to include in the LCS command.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      java.util.concurrent.CompletableFuture<java.lang.Long> append​(GlideString key, GlideString value)
      Appends a value to a key.
      java.util.concurrent.CompletableFuture<java.lang.Long> append​(java.lang.String key, java.lang.String value)
      Appends a value to a key.
      java.util.concurrent.CompletableFuture<java.lang.Long> decr​(GlideString key)
      Decrements the number stored at key by one.
      java.util.concurrent.CompletableFuture<java.lang.Long> decr​(java.lang.String key)
      Decrements the number stored at key by one.
      java.util.concurrent.CompletableFuture<java.lang.Long> decrBy​(GlideString key, long amount)
      Decrements the number stored at key by amount.
      java.util.concurrent.CompletableFuture<java.lang.Long> decrBy​(java.lang.String key, long amount)
      Decrements the number stored at key by amount.
      java.util.concurrent.CompletableFuture<GlideString> get​(GlideString key)
      Gets the value associated with the given key, or null if no such key exists.
      java.util.concurrent.CompletableFuture<java.lang.String> get​(java.lang.String key)
      Gets the value associated with the given key, or null if no such key exists.
      java.util.concurrent.CompletableFuture<GlideString> getdel​(GlideString key)
      Gets a string value associated with the given key and deletes the key.
      java.util.concurrent.CompletableFuture<java.lang.String> getdel​(java.lang.String key)
      Gets a string value associated with the given key and deletes the key.
      java.util.concurrent.CompletableFuture<GlideString> getex​(GlideString key)
      Gets the value associated with the given key.
      java.util.concurrent.CompletableFuture<GlideString> getex​(GlideString key, GetExOptions options)
      Gets the value associated with the given key.
      java.util.concurrent.CompletableFuture<java.lang.String> getex​(java.lang.String key)
      Gets the value associated with the given key.
      java.util.concurrent.CompletableFuture<java.lang.String> getex​(java.lang.String key, GetExOptions options)
      Gets the value associated with the given key.
      java.util.concurrent.CompletableFuture<GlideString> getrange​(GlideString key, int start, int end)
      Returns the subGlideString of the GlideString value stored at key, determined by the offsets start and end (both are inclusive).
      java.util.concurrent.CompletableFuture<java.lang.String> getrange​(java.lang.String key, int start, int end)
      Returns the substring of the string value stored at key, determined by the offsets start and end (both are inclusive).
      java.util.concurrent.CompletableFuture<java.lang.Long> incr​(GlideString key)
      Increments the number stored at key by one.
      java.util.concurrent.CompletableFuture<java.lang.Long> incr​(java.lang.String key)
      Increments the number stored at key by one.
      java.util.concurrent.CompletableFuture<java.lang.Long> incrBy​(GlideString key, long amount)
      Increments the number stored at key by amount.
      java.util.concurrent.CompletableFuture<java.lang.Long> incrBy​(java.lang.String key, long amount)
      Increments the number stored at key by amount.
      java.util.concurrent.CompletableFuture<java.lang.Double> incrByFloat​(GlideString key, double amount)
      Increments the string representing a floating point number stored at key by amount.
      java.util.concurrent.CompletableFuture<java.lang.Double> incrByFloat​(java.lang.String key, double amount)
      Increments the string representing a floating point number stored at key by amount.
      java.util.concurrent.CompletableFuture<GlideString> lcs​(GlideString key1, GlideString key2)
      Returns all the longest common subsequences combined between strings stored at key1 and key2.
      java.util.concurrent.CompletableFuture<java.lang.String> lcs​(java.lang.String key1, java.lang.String key2)
      Returns all the longest common subsequences combined between strings stored at key1 and key2.
      java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,​java.lang.Object>> lcsIdx​(GlideString key1, GlideString key2)
      Returns the indices and the total length of all the longest common subsequences between strings stored at key1 and key2.
      java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,​java.lang.Object>> lcsIdx​(GlideString key1, GlideString key2, long minMatchLen)
      Returns the indices and the total length of all the longest common subsequences between strings stored at key1 and key2.
      java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,​java.lang.Object>> lcsIdx​(java.lang.String key1, java.lang.String key2)
      Returns the indices and the total length of all the longest common subsequences between strings stored at key1 and key2.
      java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,​java.lang.Object>> lcsIdx​(java.lang.String key1, java.lang.String key2, long minMatchLen)
      Returns the indices and the total length of all the longest common subsequences between strings stored at key1 and key2.
      java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,​java.lang.Object>> lcsIdxWithMatchLen​(GlideString key1, GlideString key2)
      Returns the indices and lengths of the longest common subsequences between strings stored at key1 and key2.
      java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,​java.lang.Object>> lcsIdxWithMatchLen​(GlideString key1, GlideString key2, long minMatchLen)
      Returns the indices and lengths of the longest common subsequences between strings stored at key1 and key2.
      java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,​java.lang.Object>> lcsIdxWithMatchLen​(java.lang.String key1, java.lang.String key2)
      Returns the indices and lengths of the longest common subsequences between strings stored at key1 and key2.
      java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,​java.lang.Object>> lcsIdxWithMatchLen​(java.lang.String key1, java.lang.String key2, long minMatchLen)
      Returns the indices and lengths of the longest common subsequences between strings stored at key1 and key2.
      java.util.concurrent.CompletableFuture<java.lang.Long> lcsLen​(GlideString key1, GlideString key2)
      Returns the total length of all the longest common subsequences between strings stored at key1 and key2.
      java.util.concurrent.CompletableFuture<java.lang.Long> lcsLen​(java.lang.String key1, java.lang.String key2)
      Returns the total length of all the longest common subsequences between strings stored at key1 and key2.
      java.util.concurrent.CompletableFuture<GlideString[]> mget​(GlideString[] keys)
      Retrieves the values of multiple keys.
      java.util.concurrent.CompletableFuture<java.lang.String[]> mget​(java.lang.String[] keys)
      Retrieves the values of multiple keys.
      java.util.concurrent.CompletableFuture<java.lang.String> mset​(java.util.Map<java.lang.String,​java.lang.String> keyValueMap)
      Sets multiple keys to multiple values in a single operation.
      java.util.concurrent.CompletableFuture<java.lang.String> msetBinary​(java.util.Map<GlideString,​GlideString> keyValueMap)
      Sets multiple keys to multiple values in a single operation.
      java.util.concurrent.CompletableFuture<java.lang.Boolean> msetnx​(java.util.Map<java.lang.String,​java.lang.String> keyValueMap)
      Sets multiple keys to values if the key does not exist.
      java.util.concurrent.CompletableFuture<java.lang.Boolean> msetnxBinary​(java.util.Map<GlideString,​GlideString> keyValueMap)
      Sets multiple keys to values if the key does not exist.
      java.util.concurrent.CompletableFuture<java.lang.String> set​(GlideString key, GlideString value)
      Sets the given key with the given value.
      java.util.concurrent.CompletableFuture<java.lang.String> set​(GlideString key, GlideString value, SetOptions options)
      Sets the given key with the given value.
      java.util.concurrent.CompletableFuture<java.lang.String> set​(java.lang.String key, java.lang.String value)
      Sets the given key with the given value.
      java.util.concurrent.CompletableFuture<java.lang.String> set​(java.lang.String key, java.lang.String value, SetOptions options)
      Sets the given key with the given value.
      java.util.concurrent.CompletableFuture<java.lang.Long> setrange​(GlideString key, int offset, GlideString value)
      Overwrites part of the GlideString stored at key, starting at the specified offset, for the entire length of value.
      If the offset is larger than the current length of the GlideString at key , the GlideString is padded with zero bytes to make offset fit.
      java.util.concurrent.CompletableFuture<java.lang.Long> setrange​(java.lang.String key, int offset, java.lang.String value)
      Overwrites part of the string stored at key, starting at the specified offset, for the entire length of value.
      If the offset is larger than the current length of the string at key, the string is padded with zero bytes to make offset fit.
      java.util.concurrent.CompletableFuture<java.lang.Long> strlen​(GlideString key)
      Returns the length of the string value stored at key.
      java.util.concurrent.CompletableFuture<java.lang.Long> strlen​(java.lang.String key)
      Returns the length of the string value stored at key.
    • Field Detail

      • LEN_VALKEY_API

        static final java.lang.String LEN_VALKEY_API
        Valkey API keyword used to indicate that the length of the lcs should be returned.
        See Also:
        Constant Field Values
      • IDX_COMMAND_STRING

        static final java.lang.String IDX_COMMAND_STRING
        IDX option string to include in the LCS command.
        See Also:
        Constant Field Values
      • MINMATCHLEN_COMMAND_STRING

        static final java.lang.String MINMATCHLEN_COMMAND_STRING
        MINMATCHLEN option string to include in the LCS command.
        See Also:
        Constant Field Values
      • WITHMATCHLEN_COMMAND_STRING

        static final java.lang.String WITHMATCHLEN_COMMAND_STRING
        WITHMATCHLEN option string to include in the LCS command.
        See Also:
        Constant Field Values
      • LCS_MATCHES_RESULT_KEY

        static final java.lang.String LCS_MATCHES_RESULT_KEY
        Key for LCS matches result.
        See Also:
        Constant Field Values
    • Method Detail

      • get

        java.util.concurrent.CompletableFuture<java.lang.String> get​(java.lang.String key)
        Gets the value associated with the given key, or null if no such key exists.
        Parameters:
        key - The key to retrieve from the database.
        Returns:
        If key exists, returns the value of key as a String. Otherwise, return null.
        See Also:
        valkey.io for details.
        Example:
        
         String value = client.get("key").get();
         assert value.equals("value");
        
         String value = client.get("non_existing_key").get();
         assert value.equals(null);
         
      • get

        java.util.concurrent.CompletableFuture<GlideString> get​(GlideString key)
        Gets the value associated with the given key, or null if no such key exists.
        Parameters:
        key - The key to retrieve from the database.
        Returns:
        If key exists, returns the value of key as a String. Otherwise, return null.
        See Also:
        valkey.io for details.
        Example:
        
         GlideString value = client.get(gs("key")).get();
         assert Arrays.equals(value.getString(), "value");
        
         String value = client.get("non_existing_key").get();
         assert value.equals(null);
         
      • getdel

        java.util.concurrent.CompletableFuture<java.lang.String> getdel​(java.lang.String key)
        Gets a string value associated with the given key and deletes the key.
        Parameters:
        key - The key to retrieve from the database.
        Returns:
        If key exists, returns the value of key. Otherwise, return null.
        See Also:
        valkey.io for details.
        Example:
        
         String value = client.getdel("key").get();
         assert value.equals("value");
        
         String value = client.getdel("key").get();
         assert value.equals(null);
         
      • getdel

        java.util.concurrent.CompletableFuture<GlideString> getdel​(GlideString key)
        Gets a string value associated with the given key and deletes the key.
        Parameters:
        key - The key to retrieve from the database.
        Returns:
        If key exists, returns the value of key. Otherwise, return null.
        See Also:
        valkey.io for details.
        Example:
        
         GlideString value = client.getdel(gs("key")).get();
         assert value.getString().equals("value");
        
         GlideString value = client.getdel(gs("key")).get();
         assert value.equals(null);
         
      • getex

        java.util.concurrent.CompletableFuture<java.lang.String> getex​(java.lang.String key)
        Gets the value associated with the given key.
        Parameters:
        key - The key to retrieve from the database.
        Returns:
        If key exists, return the value of the key. Otherwise, return null.
        Since:
        Valkey 6.2.0.
        See Also:
        valkey.io for details.
        Example:
        
         String value = client.getex("key").get();
         assert value.equals("value");
         
      • getex

        java.util.concurrent.CompletableFuture<GlideString> getex​(GlideString key)
        Gets the value associated with the given key.
        Parameters:
        key - The key to retrieve from the database.
        Returns:
        If key exists, return the value of the key. Otherwise, return null.
        Since:
        Valkey 6.2.0.
        See Also:
        valkey.io for details.
        Example:
        
         GlideString value = client.getex(gs("key")).get();
         assert value.equals(gs("value"));
         
      • getex

        java.util.concurrent.CompletableFuture<java.lang.String> getex​(java.lang.String key,
                                                                       GetExOptions options)
        Gets the value associated with the given key.
        Parameters:
        key - The key to retrieve from the database.
        options - The GetExOptions options.
        Returns:
        If key exists, return the value of the key. Otherwise, return null.
        Since:
        Valkey 6.2.0.
        See Also:
        valkey.io for details.
        Example:
        
         String response = client.set("key", "value").get();
         assert response.equals(OK);
         String value = client.getex("key", GetExOptions.Seconds(10L)).get();
         assert value.equals("value");
         
      • getex

        java.util.concurrent.CompletableFuture<GlideString> getex​(GlideString key,
                                                                  GetExOptions options)
        Gets the value associated with the given key.
        Parameters:
        key - The key to retrieve from the database.
        options - The GetExOptions options.
        Returns:
        If key exists, return the value of the key. Otherwise, return null.
        Since:
        Valkey 6.2.0.
        See Also:
        valkey.io for details.
        Example:
        
         String response = client.set(gs("key"), gs("value").get();
         assert response.equals(OK);
         GlideString value = client.getex(gs("key"), GetExOptions.Seconds(10L)).get();
         assert value.equals(gs("value"));
         
      • set

        java.util.concurrent.CompletableFuture<java.lang.String> set​(java.lang.String key,
                                                                     java.lang.String value)
        Sets the given key with the given value.
        Parameters:
        key - The key to store.
        value - The value to store with the given key.
        Returns:
        A simple "OK" response.
        See Also:
        valkey.io for details.
        Example:
        
         String value = client.set("key", "value").get();
         assert value.equals("OK");
         
      • set

        java.util.concurrent.CompletableFuture<java.lang.String> set​(GlideString key,
                                                                     GlideString value)
        Sets the given key with the given value.
        Parameters:
        key - The key to store.
        value - The value to store with the given key.
        Returns:
        A simple "OK" response.
        See Also:
        valkey.io for details.
        Example:
        
         GlideString value = client.set(gs("key"), gs("value")).get();
         assert value.getString().equals("OK");
         
      • set

        java.util.concurrent.CompletableFuture<java.lang.String> set​(java.lang.String key,
                                                                     java.lang.String value,
                                                                     SetOptions options)
        Sets the given key with the given value. Return value is dependent on the passed options.
        Parameters:
        key - The key to store.
        value - The value to store with the given key.
        options - The Set options.
        Returns:
        If the value is successfully set, return "OK". If value isn't set because of SetOptions.ConditionalSet.ONLY_IF_EXISTS or SetOptions.ConditionalSet.ONLY_IF_DOES_NOT_EXIST or SetOptions.ConditionalSet.ONLY_IF_EQUAL conditions, return null. If SetOptions.SetOptionsBuilder.returnOldValue(boolean) is set, return the old value as a String .
        See Also:
        valkey.io for details.
        Example:
        
         SetOptions options = SetOptions.builder().conditionalSetOnlyIfExists().expiry(Seconds(5L)).build();
         String value = client.set("key", "value", options).get();
         assert value.equals("OK");
         
        
         client.set("key", "value").get();
         SetOptions options = SetOptions.builder().conditionalSetIfEqualTo("value").build();
         String value = client.set("key", "newValue", options).get();
         assert value.equals("OK");
         
      • mget

        java.util.concurrent.CompletableFuture<java.lang.String[]> mget​(java.lang.String[] keys)
        Retrieves the values of multiple keys.
        Parameters:
        keys - A list of keys to retrieve values for.
        Returns:
        An array of values corresponding to the provided keys.
        If a keyis not found, its corresponding value in the list will be null .
        See Also:
        valkey.io for details.
        Example:
        
         String values = client.mget(new String[] {"key1", "key2"}).get();
         assert values.equals(new String[] {"value1", "value2"});
         
      • mget

        java.util.concurrent.CompletableFuture<GlideString[]> mget​(GlideString[] keys)
        Retrieves the values of multiple keys.
        Parameters:
        keys - A list of keys to retrieve values for.
        Returns:
        An array of values corresponding to the provided keys.
        If a keyis not found, its corresponding value in the list will be null .
        See Also:
        valkey.io for details.
        Example:
        
         GlideString[] values = client.mget(new GlideString[] {"key1", "key2"}).get();
         assert values.equals(new GlideString[] {"value1", "value2"});
         
      • mset

        java.util.concurrent.CompletableFuture<java.lang.String> mset​(java.util.Map<java.lang.String,​java.lang.String> keyValueMap)
        Sets multiple keys to multiple values in a single operation.
        Parameters:
        keyValueMap - A key-value map consisting of keys and their respective values to set.
        Returns:
        A simple OK response.
        See Also:
        valkey.io for details.
        Example:
        
         String result = client.mset(Map.of("key1", "value1", "key2", "value2").get();
         assert result.equals("OK"));
         }
      • msetBinary

        java.util.concurrent.CompletableFuture<java.lang.String> msetBinary​(java.util.Map<GlideString,​GlideString> keyValueMap)
        Sets multiple keys to multiple values in a single operation.
        Parameters:
        keyValueMap - A key-value map consisting of keys and their respective values to set.
        Returns:
        A simple OK response.
        See Also:
        valkey.io for details.
        Example:
        
         String result = client.msetBinary(Map.of(gs("key1"), gs("value1"), gs("key2"), gs("value2")).get();
         assert result.equals("OK"));
         }
      • msetnx

        java.util.concurrent.CompletableFuture<java.lang.Boolean> msetnx​(java.util.Map<java.lang.String,​java.lang.String> keyValueMap)
        Sets multiple keys to values if the key does not exist. The operation is atomic, and if one or more keys already exist, the entire operation fails.
        Parameters:
        keyValueMap - A key-value map consisting of keys and their respective values to set.
        Returns:
        true if all keys were set. false if no key was set.
        See Also:
        valkey.io for details.
        Example:
        
         Boolean result = client.msetnx(Map.of("key1", "value1", "key2", "value2").get();
         assert result;
         }
      • msetnxBinary

        java.util.concurrent.CompletableFuture<java.lang.Boolean> msetnxBinary​(java.util.Map<GlideString,​GlideString> keyValueMap)
        Sets multiple keys to values if the key does not exist. The operation is atomic, and if one or more keys already exist, the entire operation fails.
        Parameters:
        keyValueMap - A key-value map consisting of keys and their respective values to set.
        Returns:
        true if all keys were set. false if no key was set.
        See Also:
        valkey.io for details.
        Example:
        
         Boolean result = client.msetnxBinary(Map.of(gs("key1"), gs("value1"), gs("key2"), gs("value2")).get();
         assert result;
         }
      • incr

        java.util.concurrent.CompletableFuture<java.lang.Long> incr​(java.lang.String key)
        Increments the number stored at key by one. If key does not exist, it is set to 0 before performing the operation.
        Parameters:
        key - The key to increment its value.
        Returns:
        The value of key after the increment.
        See Also:
        valkey.io for details.
        Example:
        
         Long num = client.incr("key").get();
         assert num == 5L;
         
      • incr

        java.util.concurrent.CompletableFuture<java.lang.Long> incr​(GlideString key)
        Increments the number stored at key by one. If key does not exist, it is set to 0 before performing the operation.
        Parameters:
        key - The key to increment its value.
        Returns:
        The value of key after the increment.
        See Also:
        valkey.io for details.
        Example:
        
         Long num = client.incr(gs("key")).get();
         assert num == 5L;
         
      • incrBy

        java.util.concurrent.CompletableFuture<java.lang.Long> incrBy​(java.lang.String key,
                                                                      long amount)
        Increments the number stored at key by amount. If key does not exist, it is set to 0 before performing the operation.
        Parameters:
        key - The key to increment its value.
        amount - The amount to increment.
        Returns:
        The value of key after the increment.
        See Also:
        valkey.io for details.
        Example:
        
         Long num = client.incrBy("key", 2).get();
         assert num == 7L;
         
      • incrBy

        java.util.concurrent.CompletableFuture<java.lang.Long> incrBy​(GlideString key,
                                                                      long amount)
        Increments the number stored at key by amount. If key does not exist, it is set to 0 before performing the operation.
        Parameters:
        key - The key to increment its value.
        amount - The amount to increment.
        Returns:
        The value of key after the increment.
        See Also:
        valkey.io for details.
        Example:
        
         Long num = client.incrBy(gs("key"), 2).get();
         assert num == 7L;
         
      • incrByFloat

        java.util.concurrent.CompletableFuture<java.lang.Double> incrByFloat​(java.lang.String key,
                                                                             double amount)
        Increments the string representing a floating point number stored at key by amount. By using a negative increment value, the result is that the value stored at key is decremented. If key does not exist, it is set to 0 before performing the operation.
        Parameters:
        key - The key to increment its value.
        amount - The amount to increment.
        Returns:
        The value of key after the increment.
        See Also:
        valkey.io for details.
        Example:
        
         Double num = client.incrByFloat("key", 0.5).get();
         assert num == 7.5;
         
      • incrByFloat

        java.util.concurrent.CompletableFuture<java.lang.Double> incrByFloat​(GlideString key,
                                                                             double amount)
        Increments the string representing a floating point number stored at key by amount. By using a negative increment value, the result is that the value stored at key is decremented. If key does not exist, it is set to 0 before performing the operation.
        Parameters:
        key - The key to increment its value.
        amount - The amount to increment.
        Returns:
        The value of key after the increment.
        See Also:
        valkey.io for details.
        Example:
        
         Double num = client.incrByFloat(gs("key"), 0.5).get();
         assert num == 7.5;
         
      • decr

        java.util.concurrent.CompletableFuture<java.lang.Long> decr​(java.lang.String key)
        Decrements the number stored at key by one. If key does not exist, it is set to 0 before performing the operation.
        Parameters:
        key - The key to decrement its value.
        Returns:
        The value of key after the decrement.
        See Also:
        valkey.io for details.
        Example:
        
         Long num = client.decr("key").get();
         assert num == 4L;
         
      • decr

        java.util.concurrent.CompletableFuture<java.lang.Long> decr​(GlideString key)
        Decrements the number stored at key by one. If key does not exist, it is set to 0 before performing the operation.
        Parameters:
        key - The key to decrement its value.
        Returns:
        The value of key after the decrement.
        See Also:
        valkey.io for details.
        Example:
        
         Long num = client.decr(gs("key")).get();
         assert num == 4L;
         
      • decrBy

        java.util.concurrent.CompletableFuture<java.lang.Long> decrBy​(java.lang.String key,
                                                                      long amount)
        Decrements the number stored at key by amount. If key does not exist, it is set to 0 before performing the operation.
        Parameters:
        key - The key to decrement its value.
        amount - The amount to decrement.
        Returns:
        The value of key after the decrement.
        See Also:
        valkey.io for details.
        Example:
        
         Long num = client.decrBy("key", 2).get();
         assert num == 2L;
         
      • decrBy

        java.util.concurrent.CompletableFuture<java.lang.Long> decrBy​(GlideString key,
                                                                      long amount)
        Decrements the number stored at key by amount. If key does not exist, it is set to 0 before performing the operation.
        Parameters:
        key - The key to decrement its value.
        amount - The amount to decrement.
        Returns:
        The value of key after the decrement.
        See Also:
        valkey.io for details.
        Example:
        
         Long num = client.decrBy(gs("key"), 2).get();
         assert num == 2L;
         
      • strlen

        java.util.concurrent.CompletableFuture<java.lang.Long> strlen​(java.lang.String key)
        Returns the length of the string value stored at key.
        Parameters:
        key - The key to check its length.
        Returns:
        The length of the string value stored at key.
        If key does not exist, it is treated as an empty string, and the command returns 0.
        See Also:
        valkey.io for details.
        Example:
        
         client.set("key", "GLIDE").get();
         Long len = client.strlen("key").get();
         assert len == 5L;
        
         len = client.strlen("non_existing_key").get();
         assert len == 0L;
         
      • strlen

        java.util.concurrent.CompletableFuture<java.lang.Long> strlen​(GlideString key)
        Returns the length of the string value stored at key.
        Parameters:
        key - The key to check its length.
        Returns:
        The length of the string value stored at key.
        If key does not exist, it is treated as an empty string, and the command returns 0.
        See Also:
        valkey.io for details.
        Example:
        
         client.set(gs("key"), gs("GLIDE")).get();
         Long len = client.strlen(gs("key")).get();
         assert len == 5L;
        
         len = client.strlen(gs("non_existing_key")).get();
         assert len == 0L;
         
      • setrange

        java.util.concurrent.CompletableFuture<java.lang.Long> setrange​(java.lang.String key,
                                                                        int offset,
                                                                        java.lang.String value)
        Overwrites part of the string stored at key, starting at the specified offset, for the entire length of value.
        If the offset is larger than the current length of the string at key, the string is padded with zero bytes to make offset fit. Creates the key if it doesn't exist.
        Parameters:
        key - The key of the string to update.
        offset - The position in the string where value should be written.
        value - The string written with offset.
        Returns:
        The length of the string stored at key after it was modified.
        See Also:
        valkey.io for details.
        Example:
        
         Long len = client.setrange("key", 6, "GLIDE").get();
         assert len == 11L; // New key was created with length of 11 symbols
         String value = client.get("key").get();
         assert value.equals("\0\0\0\0\0\0GLIDE"); // The string was padded with zero bytes
         
      • setrange

        java.util.concurrent.CompletableFuture<java.lang.Long> setrange​(GlideString key,
                                                                        int offset,
                                                                        GlideString value)
        Overwrites part of the GlideString stored at key, starting at the specified offset, for the entire length of value.
        If the offset is larger than the current length of the GlideString at key , the GlideString is padded with zero bytes to make offset fit. Creates the key if it doesn't exist.
        Parameters:
        key - The key of the GlideString to update.
        offset - The position in the GlideString where value should be written.
        value - The GlideString written with offset.
        Returns:
        The length of the GlideString stored at key after it was modified.
        See Also:
        valkey.io for details.
        Example:
        
         Long len = client.setrange(gs("key"), 6, gs("GLIDE")).get();
         assert len == 11L; // New key was created with length of 11 symbols
         GlideString value = client.get(gs("key")).get();
         assert value.equals(gs("\0\0\0\0\0\0GLIDE")); // The string was padded with zero bytes
         
      • getrange

        java.util.concurrent.CompletableFuture<java.lang.String> getrange​(java.lang.String key,
                                                                          int start,
                                                                          int end)
        Returns the substring of the string value stored at key, determined by the offsets start and end (both are inclusive). Negative offsets can be used in order to provide an offset starting from the end of the string. So -1 means the last character, -2 the penultimate and so forth. If key does not exist, an empty string is returned. If start or end are out of range, returns the substring within the valid range of the string.
        Parameters:
        key - The key of the string.
        start - The starting offset.
        end - The ending offset.
        Returns:
        A substring extracted from the value stored at key..
        See Also:
        valkey.io for details.
        Example:
        
         client.set("mykey", "This is a string").get();
         String substring = client.getrange("mykey", 0, 3).get();
         assert substring.equals("This");
         String substring = client.getrange("mykey", -3, -1).get();
         assert substring.equals("ing"); // extracted last 3 characters of a string
         
      • getrange

        java.util.concurrent.CompletableFuture<GlideString> getrange​(GlideString key,
                                                                     int start,
                                                                     int end)
        Returns the subGlideString of the GlideString value stored at key, determined by the offsets start and end (both are inclusive). Negative offsets can be used in order to provide an offset starting from the end of the GlideString. So -1 means the last character, -2 the penultimate and so forth. If key does not exist, an empty GlideString is returned. If start or end are out of range, returns the subGlideString within the valid range of the GlideString.
        Parameters:
        key - The key of the GlideString.
        start - The starting offset.
        end - The ending offset.
        Returns:
        A subGlideString extracted from the value stored at key..
        See Also:
        valkey.io for details.
        Example:
        
         client.set(gs("mykey"), gs("This is a GlideString")).get();
         GlideString subGlideString = client.getrange(gs("mykey"), 0, 3).get();
         assert subGlideString.equals(gs("This"));
         GlideString subGlideString = client.getrange(gs("mykey"), -3, -1).get();
         assert subGlideString.equals(gs("ing")); // extracted last 3 characters of a GlideString
         
      • append

        java.util.concurrent.CompletableFuture<java.lang.Long> append​(java.lang.String key,
                                                                      java.lang.String value)
        Appends a value to a key. If key does not exist it is created and set as an empty string, so APPEND will be similar to {@see #set} in this special case.
        Parameters:
        key - The key of the string.
        value - The value to append.
        Returns:
        The length of the string after appending the value.
        See Also:
        valkey.io for details.
        Example:
        
         Long value = client.append("key", "value").get();
         assert value.equals(5L);
         
      • append

        java.util.concurrent.CompletableFuture<java.lang.Long> append​(GlideString key,
                                                                      GlideString value)
        Appends a value to a key. If key does not exist it is created and set as an empty string, so APPEND will be similar to {@see #set} in this special case.
        Parameters:
        key - The key of the string.
        value - The value to append.
        Returns:
        The length of the string after appending the value.
        See Also:
        valkey.io for details.
        Example:
        
         Long value = client.append(gs("key"), gs("value")).get();
         assert value.equals(5L);
         
      • lcs

        java.util.concurrent.CompletableFuture<java.lang.String> lcs​(java.lang.String key1,
                                                                     java.lang.String key2)
        Returns all the longest common subsequences combined between strings stored at key1 and key2.
        Parameters:
        key1 - The key that stores the first string.
        key2 - The key that stores the second string.
        Returns:
        A String containing all the longest common subsequences combined between the 2 strings. An empty String is returned if the keys do not exist or have no common subsequences.
        Since:
        Valkey 7.0 and above.
        See Also:
        valkey.io for details.
        Example:
        
         // testKey1 = abcd, testKey2 = axcd
         String result = client.lcs("testKey1", "testKey2").get();
         assert result.equals("acd");
         
      • lcs

        java.util.concurrent.CompletableFuture<GlideString> lcs​(GlideString key1,
                                                                GlideString key2)
        Returns all the longest common subsequences combined between strings stored at key1 and key2.
        Parameters:
        key1 - The key that stores the first string.
        key2 - The key that stores the second string.
        Returns:
        A String containing all the longest common subsequences combined between the 2 strings. An empty GlideString is returned if the keys do not exist or have no common subsequences.
        Since:
        Valkey 7.0 and above.
        See Also:
        valkey.io for details.
        Example:
        
         // testKey1 = abcd, testKey2 = axcd
         GlideString result = client.lcs(gs("testKey1"), gs("testKey2")).get();
         assert result.equals(gs("acd"));
         
      • lcsLen

        java.util.concurrent.CompletableFuture<java.lang.Long> lcsLen​(java.lang.String key1,
                                                                      java.lang.String key2)
        Returns the total length of all the longest common subsequences between strings stored at key1 and key2.
        Parameters:
        key1 - The key that stores the first string.
        key2 - The key that stores the second string.
        Returns:
        The total length of all the longest common subsequences the 2 strings.
        Since:
        Valkey 7.0 and above.
        See Also:
        valkey.io for details.
        Example:
        
         // testKey1 = abcd, testKey2 = axcd
         Long result = client.lcsLen("testKey1", "testKey2").get();
         assert result.equals(3L);
         
      • lcsLen

        java.util.concurrent.CompletableFuture<java.lang.Long> lcsLen​(GlideString key1,
                                                                      GlideString key2)
        Returns the total length of all the longest common subsequences between strings stored at key1 and key2.
        Parameters:
        key1 - The key that stores the first string.
        key2 - The key that stores the second string.
        Returns:
        The length of the longest common subsequence between the 2 strings.
        Since:
        Valkey 7.0 and above.
        See Also:
        valkey.io for details.
        Example:
        
         // testKey1 = abcd, testKey2 = axcd
         Long result = client.lcsLen(gs("testKey1"), gs("testKey2")).get();
         assert result.equals(3L);
         
      • lcsIdx

        java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,​java.lang.Object>> lcsIdx​(java.lang.String key1,
                                                                                                              java.lang.String key2)
        Returns the indices and the total length of all the longest common subsequences between strings stored at key1 and key2.
        Parameters:
        key1 - The key that stores the first string.
        key2 - The key that stores the second string.
        Returns:
        A Map containing the indices of the longest common subsequence between the 2 strings and the total length of all the longest common subsequences. The resulting map contains two keys, "matches" and "len":
        • "len" is mapped to the total length of the all longest common subsequences between the 2 strings stored as Long.
        • "matches" is mapped to a three dimensional Long array that stores pairs of indices that represent the location of the common subsequences in the strings held by key1 and key2.
        See example for more details.
        Since:
        Valkey 7.0 and above.
        See Also:
        valkey.io for details.
        Example:
        
         client.mset(Map.of("key1", "abcd123", "key2", "bcdef123")).get();
         Map<String, Object> response = client.lcsIdx("key1", "key2").get();
         // the response contains data in the following format:
         Map<String, Object> data = Map.of(
             "matches", new Long[][][] {
                 {                         // the first substring match is `"123"`
                     {4L, 6L},             // in `"key1"` it is located between indices `4` and `6`
                     {5L, 7L}              // and in `"key2"` - in between `5` and `7`
                 },
                 {                         // second substring match is `"bcd"`
                     {1L, 3L},             // in `"key1"` it is located between indices `1` and `3`
                     {0L, 2L}              // and in `"key2"` - in between `0` and `2`
                 }
             },
             "len", 6                      // total length of the all matches found
         );
         
      • lcsIdx

        java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,​java.lang.Object>> lcsIdx​(GlideString key1,
                                                                                                              GlideString key2)
        Returns the indices and the total length of all the longest common subsequences between strings stored at key1 and key2.
        Parameters:
        key1 - The key that stores the first string.
        key2 - The key that stores the second string.
        Returns:
        A Map containing the indices of the longest common subsequence between the 2 strings and the total length of all the longest common subsequences. The resulting map contains two keys, "matches" and "len":
        • "len" is mapped to the total length of the all longest common subsequences between the 2 strings stored as Long.
        • "matches" is mapped to a three dimensional Long array that stores pairs of indices that represent the location of the common subsequences in the strings held by key1 and key2.
        See example for more details.
        Since:
        Valkey 7.0 and above.
        See Also:
        valkey.io for details.
        Example:
        
         client.mset(Map.of(gs("key1"), gs("abcd123"), gs("key2"), gs("bcdef123"))).get();
         Map<String, Object> response = client.lcsIdx(gs("key1"), gs("key2")).get();
         // the response contains data in the following format:
         Map<String, Object> data = Map.of(
             "matches", new Long[][][] {
                 {                         // the first substring match is `gs("123")`
                     {4L, 6L},             // in `gs("key1")` it is located between indices `4` and `6`
                     {5L, 7L}              // and in `gs("key2")` - in between `5` and `7`
                 },
                 {                         // second substring match is `gs("bcd")`
                     {1L, 3L},             // in `gs("key1")` it is located between indices `1` and `3`
                     {0L, 2L}              // and in `gs("key2")` - in between `0` and `2`
                 }
             },
             "len", 6                      // total length of the all matches found
         );
         
      • lcsIdx

        java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,​java.lang.Object>> lcsIdx​(java.lang.String key1,
                                                                                                              java.lang.String key2,
                                                                                                              long minMatchLen)
        Returns the indices and the total length of all the longest common subsequences between strings stored at key1 and key2.
        Parameters:
        key1 - The key that stores the first string.
        key2 - The key that stores the second string.
        minMatchLen - The minimum length of matches to include in the result.
        Returns:
        A Map containing the indices of the longest common subsequence between the 2 strings and the total length of all the longest common subsequences. The resulting map contains two keys, "matches" and "len":
        • "len" is mapped to the total length of the all longest common subsequences between the 2 strings stored as Long. This value doesn't count towards the minMatchLen filter.
        • "matches" is mapped to a three dimensional Long array that stores pairs of indices that represent the location of the common subsequences in the strings held by key1 and key2.
        See example for more details.
        Since:
        Valkey 7.0 and above.
        See Also:
        valkey.io for details.
        Example:
        
         client.mset(Map.of("key1", "abcd123", "key2", "bcdef123")).get();
         Map<String, Object> response = client.lcsIdx("key1", "key2", 2).get();
         // the response contains data in the following format:
         Map<String, Object> data = Map.of(
             "matches", new Long[][][] {
                 {                         // the first substring match is `"123"`
                     {4L, 6L},             // in `"key1"` it is located between indices `4` and `6`
                     {5L, 7L}              // and in `"key2"` - in between `5` and `7`
                 },
                 {                         // second substring match is `"bcd"`
                     {1L, 3L},             // in `"key1"` it is located between indices `1` and `3`
                     {0L, 2L}              // and in `"key2"` - in between `0` and `2`
                 }
             },
             "len", 6                      // total length of the all matches found
         );
         
      • lcsIdx

        java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,​java.lang.Object>> lcsIdx​(GlideString key1,
                                                                                                              GlideString key2,
                                                                                                              long minMatchLen)
        Returns the indices and the total length of all the longest common subsequences between strings stored at key1 and key2.
        Parameters:
        key1 - The key that stores the first string.
        key2 - The key that stores the second string.
        minMatchLen - The minimum length of matches to include in the result.
        Returns:
        A Map containing the indices of the longest common subsequence between the 2 strings and the total length of all the longest common subsequences. The resulting map contains two keys, "matches" and "len":
        • "len" is mapped to the total length of the all longest common subsequences between the 2 strings stored as Long. This value doesn't count towards the minMatchLen filter.
        • "matches" is mapped to a three dimensional Long array that stores pairs of indices that represent the location of the common subsequences in the strings held by key1 and key2.
        See example for more details.
        Since:
        Valkey 7.0 and above.
        See Also:
        valkey.io for details.
        Example:
        
         client.mset(Map.of(gs("key1"), gs("abcd123"), gs("key2"), gs("bcdef123"))).get();
         Map<String, Object> response = client.lcsIdx(gs("key1"), gs("key2"), 2).get();
         // the response contains data in the following format:
         Map<String, Object> data = Map.of(
             "matches", new Long[][][] {
                 {                         // the first substring match is `gs("123")`
                     {4L, 6L},             // in `gs("key1")` it is located between indices `4` and `6`
                     {5L, 7L}              // and in `gs("key2")` - in between `5` and `7`
                 },
                 {                         // second substring match is `gs("bcd")`
                     {1L, 3L},             // in `gs("key1")` it is located between indices `1` and `3`
                     {0L, 2L}              // and in `gs("key2")` - in between `0` and `2`
                 }
             },
             "len", 6                      // total length of the all matches found
         );
         
      • lcsIdxWithMatchLen

        java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,​java.lang.Object>> lcsIdxWithMatchLen​(java.lang.String key1,
                                                                                                                          java.lang.String key2)
        Returns the indices and lengths of the longest common subsequences between strings stored at key1 and key2.
        Parameters:
        key1 - The key that stores the first string.
        key2 - The key that stores the second string.
        Returns:
        A Map containing the indices of the longest common subsequence between the 2 strings and the lengths of the longest common subsequences. The resulting map contains two keys, "matches" and "len":
        • "len" is mapped to the total length of the all longest common subsequences between the 2 strings stored as Long.
        • "matches" is mapped to a three dimensional array that stores pairs of indices that represent the location of the common subsequences in the strings held by key1 and key2 and the match length.
        See example for more details.
        Since:
        Valkey 7.0 and above.
        See Also:
        valkey.io for details.
        Example:
        
         client.mset(Map.of("key1", "abcd1234", "key2", "bcdef1234")).get();
         Map<String, Object> response = client.lcsIdxWithMatchLen("key1", "key2").get();
         // the response contains data in the following format:
         Map<String, Object> data = Map.of(
             "matches", new Object[][] {
                 {                                    // the first substring match is `"1234"`
                     new Long[] {4L, 7L},             // in `"key1"` it is located between indices `4` and `7`
                     new Long[] {5L, 8L},             // and in `"key2"` - in between `5` and `8`
                     4L                               // the match length
                 },
                 {                                    // second substring match is `"bcd"`
                     new Long[] {1L, 3L},             // in `"key1"` it is located between indices `1` and `3`
                     new Long[] {0L, 2L},             // and in `"key2"` - in between `0` and `2`
                     3L                               // the match length
                 }
             },
             "len", 6                                 // total length of the all matches found
         );
         
      • lcsIdxWithMatchLen

        java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,​java.lang.Object>> lcsIdxWithMatchLen​(GlideString key1,
                                                                                                                          GlideString key2)
        Returns the indices and lengths of the longest common subsequences between strings stored at key1 and key2.
        Parameters:
        key1 - The key that stores the first string.
        key2 - The key that stores the second string.
        Returns:
        A Map containing the indices of the longest common subsequence between the 2 strings and the lengths of the longest common subsequences. The resulting map contains two keys, "matches" and "len":
        • "len" is mapped to the total length of the all longest common subsequences between the 2 strings stored as Long.
        • "matches" is mapped to a three dimensional array that stores pairs of indices that represent the location of the common subsequences in the strings held by key1 and key2 and the match length.
        See example for more details.
        Since:
        Valkey 7.0 and above.
        See Also:
        valkey.io for details.
        Example:
        
         client.mset(Map.of(gs("key1"), gs("abcd1234"), gs("key2"), gs("bcdef1234"))).get();
         Map<String, Object> response = client.lcsIdxWithMatchLen(gs("key1"), gs("key2")).get();
         // the response contains data in the following format:
         Map<String, Object> data = Map.of(
             "matches", new Object[][] {
                 {                                    // the first substring match is `gs("1234")`
                     new Long[] {4L, 7L},             // in `gs("key1")` it is located between indices `4` and `7`
                     new Long[] {5L, 8L},             // and in `gs("key2")` - in between `5` and `8`
                     4L                               // the match length
                 },
                 {                                    // second substring match is `"bcd"`
                     new Long[] {1L, 3L},             // in `gs("key1")` it is located between indices `1` and `3`
                     new Long[] {0L, 2L},             // and in `gs("key2")` - in between `0` and `2`
                     3L                               // the match length
                 }
             },
             "len", 6                                 // total length of the all matches found
         );
         
      • lcsIdxWithMatchLen

        java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,​java.lang.Object>> lcsIdxWithMatchLen​(java.lang.String key1,
                                                                                                                          java.lang.String key2,
                                                                                                                          long minMatchLen)
        Returns the indices and lengths of the longest common subsequences between strings stored at key1 and key2.
        Parameters:
        key1 - The key that stores the first string.
        key2 - The key that stores the second string.
        minMatchLen - The minimum length of matches to include in the result.
        Returns:
        A Map containing the indices of the longest common subsequence between the 2 strings and the total length of all the longest common subsequences. The resulting map contains two keys, "matches" and "len":
        • "len" is mapped to the total length of the all longest common subsequences between the 2 strings stored as Long. This value doesn't count towards the minMatchLen filter.
        • "matches" is mapped to a three dimensional array that stores pairs of indices that represent the location of the common subsequences in the strings held by key1 and key2 and the match length.
        See example for more details.
        Since:
        Valkey 7.0 and above.
        See Also:
        valkey.io for details.
        Example:
        
         client.mset(Map.of("key1", "abcd1234", "key2", "bcdef1234")).get();
         Map<String, Object> response = client.lcsIdxWithMatchLen("key1", "key2", 2).get();
         // the response contains data in the following format:
         Map<String, Object> data = Map.of(
             "matches", new Object[][] {
                 {                                    // the first substring match is `"1234"`
                     new Long[] {4L, 7L},             // in `"key1"` it is located between indices `4` and `7`
                     new Long[] {5L, 8L},             // and in `"key2"` - in between `5` and `8`
                     4L                               // the match length
                 },
                 {                                    // second substring match is `"bcd"`
                     new Long[] {1L, 3L},             // in `"key1"` it is located between indices `1` and `3`
                     new Long[] {0L, 2L},             // and in `"key2"` - in between `0` and `2`
                     3L                               // the match length
                 }
             },
             "len", 6                                 // total length of the all matches found
         );
         
      • lcsIdxWithMatchLen

        java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,​java.lang.Object>> lcsIdxWithMatchLen​(GlideString key1,
                                                                                                                          GlideString key2,
                                                                                                                          long minMatchLen)
        Returns the indices and lengths of the longest common subsequences between strings stored at key1 and key2.
        Parameters:
        key1 - The key that stores the first string.
        key2 - The key that stores the second string.
        minMatchLen - The minimum length of matches to include in the result.
        Returns:
        A Map containing the indices of the longest common subsequence between the 2 strings and the total length of all the longest common subsequences. The resulting map contains two keys, "matches" and "len":
        • "len" is mapped to the total length of the all longest common subsequences between the 2 strings stored as Long. This value doesn't count towards the minMatchLen filter.
        • "matches" is mapped to a three dimensional array that stores pairs of indices that represent the location of the common subsequences in the strings held by key1 and key2 and the match length.
        See example for more details.
        Since:
        Valkey 7.0 and above.
        See Also:
        valkey.io for details.
        Example:
        
         client.mset(Map.of(gs("key1"), gs("abcd1234"), gs("key2"), gs("bcdef1234"))).get();
         Map<String, Object> response = client.lcsIdxWithMatchLen(gs("key1"), gs("key2"), 2).get();
         // the response contains data in the following format:
         Map<String, Object> data = Map.of(
             "matches", new Object[][] {
                 {                                    // the first substring match is `gs("1234")`
                     new Long[] {4L, 7L},             // in `gs("key1")` it is located between indices `4` and `7`
                     new Long[] {5L, 8L},             // and in `gs("key2")` - in between `5` and `8`
                     4L                               // the match length
                 },
                 {                                    // second substring match is `"bcd"`
                     new Long[] {1L, 3L},             // in `gs("key1")` it is located between indices `1` and `3`
                     new Long[] {0L, 2L},             // and in `gs("key2")` - in between `0` and `2`
                     3L                               // the match length
                 }
             },
             "len", 6                                 // total length of the all matches found
         );