Package glide.api.commands
Interface StringBaseCommands
-
- All Known Implementing Classes:
BaseClient,GlideClient,GlideClusterClient
public interface StringBaseCommandsSupports commands for the "String Commands" group for standalone and cluster clients.- See Also:
- String Commands
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringIDX_COMMAND_STRINGIDXoption string to include in theLCScommand.static java.lang.StringLCS_MATCHES_RESULT_KEYKey for LCS matches result.static java.lang.StringLEN_VALKEY_APIValkey API keyword used to indicate that the length of the lcs should be returned.static java.lang.StringMINMATCHLEN_COMMAND_STRINGMINMATCHLENoption string to include in theLCScommand.static java.lang.StringWITHMATCHLEN_COMMAND_STRINGWITHMATCHLENoption string to include in theLCScommand.
-
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 avalueto akey.java.util.concurrent.CompletableFuture<java.lang.Long>append(java.lang.String key, java.lang.String value)Appends avalueto akey.java.util.concurrent.CompletableFuture<java.lang.Long>decr(GlideString key)Decrements the number stored atkeyby one.java.util.concurrent.CompletableFuture<java.lang.Long>decr(java.lang.String key)Decrements the number stored atkeyby one.java.util.concurrent.CompletableFuture<java.lang.Long>decrBy(GlideString key, long amount)Decrements the number stored atkeybyamount.java.util.concurrent.CompletableFuture<java.lang.Long>decrBy(java.lang.String key, long amount)Decrements the number stored atkeybyamount.java.util.concurrent.CompletableFuture<GlideString>get(GlideString key)Gets the value associated with the givenkey, ornullif no suchkeyexists.java.util.concurrent.CompletableFuture<java.lang.String>get(java.lang.String key)Gets the value associated with the givenkey, ornullif no suchkeyexists.java.util.concurrent.CompletableFuture<GlideString>getdel(GlideString key)Gets a string value associated with the givenkeyand deletes the key.java.util.concurrent.CompletableFuture<java.lang.String>getdel(java.lang.String key)Gets a string value associated with the givenkeyand deletes the key.java.util.concurrent.CompletableFuture<GlideString>getex(GlideString key)Gets the value associated with the givenkey.java.util.concurrent.CompletableFuture<GlideString>getex(GlideString key, GetExOptions options)Gets the value associated with the givenkey.java.util.concurrent.CompletableFuture<java.lang.String>getex(java.lang.String key)Gets the value associated with the givenkey.java.util.concurrent.CompletableFuture<java.lang.String>getex(java.lang.String key, GetExOptions options)Gets the value associated with the givenkey.java.util.concurrent.CompletableFuture<GlideString>getrange(GlideString key, int start, int end)Returns the subGlideString of the GlideString value stored atkey, determined by the offsetsstartandend(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 atkey, determined by the offsetsstartandend(both are inclusive).java.util.concurrent.CompletableFuture<java.lang.Long>incr(GlideString key)Increments the number stored atkeyby one.java.util.concurrent.CompletableFuture<java.lang.Long>incr(java.lang.String key)Increments the number stored atkeyby one.java.util.concurrent.CompletableFuture<java.lang.Long>incrBy(GlideString key, long amount)Increments the number stored atkeybyamount.java.util.concurrent.CompletableFuture<java.lang.Long>incrBy(java.lang.String key, long amount)Increments the number stored atkeybyamount.java.util.concurrent.CompletableFuture<java.lang.Double>incrByFloat(GlideString key, double amount)Increments the string representing a floating point number stored atkeybyamount.java.util.concurrent.CompletableFuture<java.lang.Double>incrByFloat(java.lang.String key, double amount)Increments the string representing a floating point number stored atkeybyamount.java.util.concurrent.CompletableFuture<GlideString>lcs(GlideString key1, GlideString key2)Returns all the longest common subsequences combined between strings stored atkey1andkey2.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 atkey1andkey2.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 atkey1andkey2.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 atkey1andkey2.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 atkey1andkey2.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 atkey1andkey2.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 atkey1andkey2.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 atkey1andkey2.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 atkey1andkey2.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 atkey1andkey2.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 atkey1andkey2.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 atkey1andkey2.java.util.concurrent.CompletableFuture<GlideString[]>mget(GlideString[] keys)Retrieves the values of multiplekeys.java.util.concurrent.CompletableFuture<java.lang.String[]>mget(java.lang.String[] keys)Retrieves the values of multiplekeys.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 givenkeywith 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 givenkeywith 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 atkey, starting at the specifiedoffset, for the entire length ofvalue.
If theoffsetis larger than the current length of the GlideString atkey, the GlideString is padded with zero bytes to makeoffsetfit.java.util.concurrent.CompletableFuture<java.lang.Long>setrange(java.lang.String key, int offset, java.lang.String value)Overwrites part of the string stored atkey, starting at the specifiedoffset, for the entire length ofvalue.
If theoffsetis larger than the current length of the string atkey, the string is padded with zero bytes to makeoffsetfit.java.util.concurrent.CompletableFuture<java.lang.Long>strlen(GlideString key)Returns the length of the string value stored atkey.java.util.concurrent.CompletableFuture<java.lang.Long>strlen(java.lang.String key)Returns the length of the string value stored atkey.
-
-
-
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
IDXoption string to include in theLCScommand.- See Also:
- Constant Field Values
-
MINMATCHLEN_COMMAND_STRING
static final java.lang.String MINMATCHLEN_COMMAND_STRING
MINMATCHLENoption string to include in theLCScommand.- See Also:
- Constant Field Values
-
WITHMATCHLEN_COMMAND_STRING
static final java.lang.String WITHMATCHLEN_COMMAND_STRING
WITHMATCHLENoption string to include in theLCScommand.- 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 givenkey, ornullif no suchkeyexists.- Parameters:
key- Thekeyto retrieve from the database.- Returns:
- If
keyexists, returns thevalueofkeyas aString. Otherwise, returnnull. - 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 givenkey, ornullif no suchkeyexists.- Parameters:
key- Thekeyto retrieve from the database.- Returns:
- If
keyexists, returns thevalueofkeyas aString. Otherwise, returnnull. - 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 givenkeyand deletes the key.- Parameters:
key- Thekeyto retrieve from the database.- Returns:
- If
keyexists, returns thevalueofkey. Otherwise, returnnull. - 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 givenkeyand deletes the key.- Parameters:
key- Thekeyto retrieve from the database.- Returns:
- If
keyexists, returns thevalueofkey. Otherwise, returnnull. - 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 givenkey.- Parameters:
key- Thekeyto retrieve from the database.- Returns:
- If
keyexists, return thevalueof thekey. Otherwise, returnnull. - 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 givenkey.- Parameters:
key- Thekeyto retrieve from the database.- Returns:
- If
keyexists, return thevalueof thekey. Otherwise, returnnull. - 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 givenkey.- Parameters:
key- Thekeyto retrieve from the database.options- TheGetExOptionsoptions.- Returns:
- If
keyexists, return thevalueof thekey. Otherwise, returnnull. - 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 givenkey.- Parameters:
key- Thekeyto retrieve from the database.options- TheGetExOptionsoptions.- Returns:
- If
keyexists, return thevalueof thekey. Otherwise, returnnull. - 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 givenkeywith the given value.- Parameters:
key- Thekeyto store.value- The value to store with the givenkey.- 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 givenkeywith the given value.- Parameters:
key- Thekeyto store.value- The value to store with the givenkey.- 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 ofSetOptions.ConditionalSet.ONLY_IF_EXISTSorSetOptions.ConditionalSet.ONLY_IF_DOES_NOT_EXISTorSetOptions.ConditionalSet.ONLY_IF_EQUALconditions, returnnull. IfSetOptions.SetOptionsBuilder.returnOldValue(boolean)is set, return the old value as aString. - 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");
-
set
java.util.concurrent.CompletableFuture<java.lang.String> set(GlideString key, GlideString 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 ofSetOptions.ConditionalSet.ONLY_IF_EXISTSorSetOptions.ConditionalSet.ONLY_IF_DOES_NOT_EXISTorSetOptions.ConditionalSet.ONLY_IF_EQUALconditions, returnnull. IfSetOptions.SetOptionsBuilder.returnOldValue(boolean)is set, return the old value as aString. - See Also:
- valkey.io for details.
- Example:
SetOptions options = SetOptions.builder().conditionalSet(ONLY_IF_EXISTS).expiry(Seconds(5L)).build(); String value = client.set("key".getBytes(), "value".getBytes(), options).get(); assert value.equals("OK");
-
mget
java.util.concurrent.CompletableFuture<java.lang.String[]> mget(java.lang.String[] keys)
Retrieves the values of multiplekeys.- Parameters:
keys- A list of keys to retrieve values for.- Returns:
- An array of values corresponding to the provided
keys.
If akeyis not found, its corresponding value in the list will benull. - 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 multiplekeys.- Parameters:
keys- A list of keys to retrieve values for.- Returns:
- An array of values corresponding to the provided
keys.
If akeyis not found, its corresponding value in the list will benull. - 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
OKresponse. - 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
OKresponse. - 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:
trueif all keys were set.falseif 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:
trueif all keys were set.falseif 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 atkeyby one. Ifkeydoes not exist, it is set to 0 before performing the operation.- Parameters:
key- The key to increment its value.- Returns:
- The value of
keyafter 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 atkeyby one. Ifkeydoes not exist, it is set to 0 before performing the operation.- Parameters:
key- The key to increment its value.- Returns:
- The value of
keyafter 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 atkeybyamount. Ifkeydoes 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
keyafter 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 atkeybyamount. Ifkeydoes 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
keyafter 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 atkeybyamount. By using a negative increment value, the result is that the value stored atkeyis decremented. Ifkeydoes 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
keyafter 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 atkeybyamount. By using a negative increment value, the result is that the value stored atkeyis decremented. Ifkeydoes 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
keyafter 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 atkeyby one. Ifkeydoes not exist, it is set to 0 before performing the operation.- Parameters:
key- The key to decrement its value.- Returns:
- The value of
keyafter 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 atkeyby one. Ifkeydoes not exist, it is set to 0 before performing the operation.- Parameters:
key- The key to decrement its value.- Returns:
- The value of
keyafter 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 atkeybyamount. Ifkeydoes 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
keyafter 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 atkeybyamount. Ifkeydoes 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
keyafter 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 atkey.- Parameters:
key- The key to check its length.- Returns:
- The length of the string value stored at key.
Ifkeydoes not exist, it is treated as an empty string, and the command returns0. - 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 atkey.- Parameters:
key- The key to check its length.- Returns:
- The length of the string value stored at key.
Ifkeydoes not exist, it is treated as an empty string, and the command returns0. - 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 atkey, starting at the specifiedoffset, for the entire length ofvalue.
If theoffsetis larger than the current length of the string atkey, the string is padded with zero bytes to makeoffsetfit. Creates thekeyif it doesn't exist.- Parameters:
key- The key of the string to update.offset- The position in the string wherevalueshould be written.value- The string written withoffset.- Returns:
- The length of the string stored at
keyafter 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 atkey, starting at the specifiedoffset, for the entire length ofvalue.
If theoffsetis larger than the current length of the GlideString atkey, the GlideString is padded with zero bytes to makeoffsetfit. Creates thekeyif it doesn't exist.- Parameters:
key- The key of the GlideString to update.offset- The position in the GlideString wherevalueshould be written.value- The GlideString written withoffset.- Returns:
- The length of the GlideString stored at
keyafter 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 atkey, determined by the offsetsstartandend(both are inclusive). Negative offsets can be used in order to provide an offset starting from the end of the string. So-1means the last character,-2the penultimate and so forth. Ifkeydoes not exist, an empty string is returned. Ifstartorendare 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 atkey, determined by the offsetsstartandend(both are inclusive). Negative offsets can be used in order to provide an offset starting from the end of the GlideString. So-1means the last character,-2the penultimate and so forth. Ifkeydoes not exist, an empty GlideString is returned. Ifstartorendare 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 avalueto akey. Ifkeydoes not exist it is created and set as an empty string, soAPPENDwill 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 avalueto akey. Ifkeydoes not exist it is created and set as an empty string, soAPPENDwill 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 atkey1andkey2.- Parameters:
key1- The key that stores the first string.key2- The key that stores the second string.- Returns:
- A
Stringcontaining all the longest common subsequences combined between the 2 strings. An emptyStringis 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 atkey1andkey2.- Parameters:
key1- The key that stores the first string.key2- The key that stores the second string.- Returns:
- A
Stringcontaining all the longest common subsequences combined between the 2 strings. An emptyGlideStringis 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 atkey1andkey2.- 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 atkey1andkey2.- 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 atkey1andkey2.- Parameters:
key1- The key that stores the first string.key2- The key that stores the second string.- Returns:
- A
Mapcontaining 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
Longarray that stores pairs of indices that represent the location of the common subsequences in the strings held bykey1andkey2.
- "len" is mapped to the total length of the all longest common subsequences between
the 2 strings stored as
- 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 atkey1andkey2.- Parameters:
key1- The key that stores the first string.key2- The key that stores the second string.- Returns:
- A
Mapcontaining 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
Longarray that stores pairs of indices that represent the location of the common subsequences in the strings held bykey1andkey2.
- "len" is mapped to the total length of the all longest common subsequences between
the 2 strings stored as
- 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 atkey1andkey2.- 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
Mapcontaining 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 theminMatchLenfilter. - "matches" is mapped to a three dimensional
Longarray that stores pairs of indices that represent the location of the common subsequences in the strings held bykey1andkey2.
- "len" is mapped to the total length of the all longest common subsequences between
the 2 strings stored as
- 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 atkey1andkey2.- 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
Mapcontaining 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 theminMatchLenfilter. - "matches" is mapped to a three dimensional
Longarray that stores pairs of indices that represent the location of the common subsequences in the strings held bykey1andkey2.
- "len" is mapped to the total length of the all longest common subsequences between
the 2 strings stored as
- 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 atkey1andkey2.- Parameters:
key1- The key that stores the first string.key2- The key that stores the second string.- Returns:
- A
Mapcontaining 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
key1andkey2and the match length.
- "len" is mapped to the total length of the all longest common subsequences between
the 2 strings stored as
- 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 atkey1andkey2.- Parameters:
key1- The key that stores the first string.key2- The key that stores the second string.- Returns:
- A
Mapcontaining 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
key1andkey2and the match length.
- "len" is mapped to the total length of the all longest common subsequences between
the 2 strings stored as
- 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 atkey1andkey2.- 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
Mapcontaining 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 theminMatchLenfilter. - "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
key1andkey2and the match length.
- "len" is mapped to the total length of the all longest common subsequences between
the 2 strings stored as
- 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 atkey1andkey2.- 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
Mapcontaining 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 theminMatchLenfilter. - "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
key1andkey2and the match length.
- "len" is mapped to the total length of the all longest common subsequences between
the 2 strings stored as
- 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 );
-
-