Package glide.api.commands
Interface BitmapBaseCommands
-
- All Known Implementing Classes:
BaseClient,GlideClient,GlideClusterClient
public interface BitmapBaseCommandsSupports commands for the "Bitmap Commands" group for standalone and cluster clients.- See Also:
- Bitmap Commands
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.util.concurrent.CompletableFuture<java.lang.Long>bitcount(GlideString key)Counts the number of set bits (population counting) in a string stored atkey.java.util.concurrent.CompletableFuture<java.lang.Long>bitcount(GlideString key, long start)Counts the number of set bits (population counting) in a string stored atkey.java.util.concurrent.CompletableFuture<java.lang.Long>bitcount(GlideString key, long start, long end)Counts the number of set bits (population counting) in a string stored atkey.java.util.concurrent.CompletableFuture<java.lang.Long>bitcount(GlideString key, long start, long end, BitmapIndexType options)Counts the number of set bits (population counting) in a string stored atkey.java.util.concurrent.CompletableFuture<java.lang.Long>bitcount(java.lang.String key)Counts the number of set bits (population counting) in a string stored atkey.java.util.concurrent.CompletableFuture<java.lang.Long>bitcount(java.lang.String key, long start)Counts the number of set bits (population counting) in a string stored atkey.java.util.concurrent.CompletableFuture<java.lang.Long>bitcount(java.lang.String key, long start, long end)Counts the number of set bits (population counting) in a string stored atkey.java.util.concurrent.CompletableFuture<java.lang.Long>bitcount(java.lang.String key, long start, long end, BitmapIndexType options)Counts the number of set bits (population counting) in a string stored atkey.java.util.concurrent.CompletableFuture<java.lang.Long[]>bitfield(GlideString key, BitFieldOptions.BitFieldSubCommands[] subCommands)Reads or modifies the array of bits representing the string that is held atkeybased on the specifiedsubCommands.java.util.concurrent.CompletableFuture<java.lang.Long[]>bitfield(java.lang.String key, BitFieldOptions.BitFieldSubCommands[] subCommands)Reads or modifies the array of bits representing the string that is held atkeybased on the specifiedsubCommands.java.util.concurrent.CompletableFuture<java.lang.Long[]>bitfieldReadOnly(GlideString key, BitFieldOptions.BitFieldReadOnlySubCommands[] subCommands)Reads the array of bits representing the string that is held atkeybased on the specifiedsubCommands.
This command is routed depending on the client'sReadFromstrategy.java.util.concurrent.CompletableFuture<java.lang.Long[]>bitfieldReadOnly(java.lang.String key, BitFieldOptions.BitFieldReadOnlySubCommands[] subCommands)Reads the array of bits representing the string that is held atkeybased on the specifiedsubCommands.
This command is routed depending on the client'sReadFromstrategy.java.util.concurrent.CompletableFuture<java.lang.Long>bitop(BitwiseOperation bitwiseOperation, GlideString destination, GlideString[] keys)Perform a bitwise operation between multiple keys (containing string values) and store the result in thedestination.java.util.concurrent.CompletableFuture<java.lang.Long>bitop(BitwiseOperation bitwiseOperation, java.lang.String destination, java.lang.String[] keys)Perform a bitwise operation between multiple keys (containing string values) and store the result in thedestination.java.util.concurrent.CompletableFuture<java.lang.Long>bitpos(GlideString key, long bit)Returns the position of the first bit matching the givenbitvalue.java.util.concurrent.CompletableFuture<java.lang.Long>bitpos(GlideString key, long bit, long start)Returns the position of the first bit matching the givenbitvalue.java.util.concurrent.CompletableFuture<java.lang.Long>bitpos(GlideString key, long bit, long start, long end)Returns the position of the first bit matching the givenbitvalue.java.util.concurrent.CompletableFuture<java.lang.Long>bitpos(GlideString key, long bit, long start, long end, BitmapIndexType offsetType)Returns the position of the first bit matching the givenbitvalue.java.util.concurrent.CompletableFuture<java.lang.Long>bitpos(java.lang.String key, long bit)Returns the position of the first bit matching the givenbitvalue.java.util.concurrent.CompletableFuture<java.lang.Long>bitpos(java.lang.String key, long bit, long start)Returns the position of the first bit matching the givenbitvalue.java.util.concurrent.CompletableFuture<java.lang.Long>bitpos(java.lang.String key, long bit, long start, long end)Returns the position of the first bit matching the givenbitvalue.java.util.concurrent.CompletableFuture<java.lang.Long>bitpos(java.lang.String key, long bit, long start, long end, BitmapIndexType offsetType)Returns the position of the first bit matching the givenbitvalue.java.util.concurrent.CompletableFuture<java.lang.Long>getbit(GlideString key, long offset)Returns the bit value atoffsetin the string value stored atkey.java.util.concurrent.CompletableFuture<java.lang.Long>getbit(java.lang.String key, long offset)Returns the bit value atoffsetin the string value stored atkey.java.util.concurrent.CompletableFuture<java.lang.Long>setbit(GlideString key, long offset, long value)Sets or clears the bit atoffsetin the string value stored atkey.java.util.concurrent.CompletableFuture<java.lang.Long>setbit(java.lang.String key, long offset, long value)Sets or clears the bit atoffsetin the string value stored atkey.
-
-
-
Method Detail
-
bitcount
java.util.concurrent.CompletableFuture<java.lang.Long> bitcount(java.lang.String key)
Counts the number of set bits (population counting) in a string stored atkey.- Parameters:
key- The key for the string to count the set bits of.- Returns:
- The number of set bits in the string. Returns zero if the key is missing as it is treated as an empty string.
- See Also:
- valkey.io for details.
- Example:
Long payload = client.bitcount("myKey1").get(); assert payload == 2L; // The string stored at "myKey1" contains 2 set bits.
-
bitcount
java.util.concurrent.CompletableFuture<java.lang.Long> bitcount(GlideString key)
Counts the number of set bits (population counting) in a string stored atkey.- Parameters:
key- The key for the string to count the set bits of.- Returns:
- The number of set bits in the string. Returns zero if the key is missing as it is treated as an empty string.
- See Also:
- valkey.io for details.
- Example:
Long payload = client.bitcount(gs("myKey1")).get(); assert payload == 2L; // The string stored at "myKey1" contains 2 set bits.
-
bitcount
java.util.concurrent.CompletableFuture<java.lang.Long> bitcount(java.lang.String key, long start)Counts the number of set bits (population counting) in a string stored atkey. The offsetstartis a zero-based index, with0being the first byte of the list,1being the next byte and so on. This offset can also be a negative number indicating offsets starting at the end of the list, with-1being the last byte of the list,-2being the penultimate, and so on.- Parameters:
key- The key for the string to count the set bits of.start- The starting offset byte index.- Returns:
- The number of set bits in the string byte interval specified by
startto the last byte. Returns zero if the key is missing as it is treated as an empty string. - Since:
- Valkey 8.0 and above
- See Also:
- valkey.io for details.
- Example:
Long payload = client.bitcount("myKey1", 1).get(); assert payload == 2L; // From the second to the last bytes of the string stored at "myKey1" are 2 set bits.
-
bitcount
java.util.concurrent.CompletableFuture<java.lang.Long> bitcount(GlideString key, long start)
Counts the number of set bits (population counting) in a string stored atkey. The offsetstartis a zero-based index, with0being the first byte of the list,1being the next byte and so on. This offset can also be a negative number indicating offsets starting at the end of the list, with-1being the last byte of the list,-2being the penultimate, and so on.- Parameters:
key- The key for the string to count the set bits of.start- The starting offset byte index.- Returns:
- The number of set bits in the string byte interval specified by
startto the last byte. Returns zero if the key is missing as it is treated as an empty string. - Since:
- Valkey 8.0 and above
- See Also:
- valkey.io for details.
- Example:
Long payload = client.bitcount(gs("myKey1"), 1).get(); assert payload == 2L; // From the second to the last bytes of the string stored at "myKey1" are 2 set bits.
-
bitcount
java.util.concurrent.CompletableFuture<java.lang.Long> bitcount(java.lang.String key, long start, long end)Counts the number of set bits (population counting) in a string stored atkey. The offsetsstartandendare zero-based indexes, with0being the first element of the list,1being the next element and so on. These offsets can also be negative numbers indicating offsets starting at the end of the list, with-1being the last element of the list,-2being the penultimate, and so on.- Parameters:
key- The key for the string to count the set bits of.start- The starting offset byte index.end- The ending offset byte index.- Returns:
- The number of set bits in the string byte interval specified by
startandend. Returns zero if the key is missing as it is treated as an empty string. - See Also:
- valkey.io for details.
- Example:
Long payload = client.bitcount("myKey1", 1, 3).get(); assert payload == 2L; // The second to fourth bytes of the string stored at "myKey1" contains 2 set bits.
-
bitcount
java.util.concurrent.CompletableFuture<java.lang.Long> bitcount(GlideString key, long start, long end)
Counts the number of set bits (population counting) in a string stored atkey. The offsetsstartandendare zero-based indexes, with0being the first element of the list,1being the next element and so on. These offsets can also be negative numbers indicating offsets starting at the end of the list, with-1being the last element of the list,-2being the penultimate, and so on.- Parameters:
key- The key for the string to count the set bits of.start- The starting offset byte index.end- The ending offset byte index.- Returns:
- The number of set bits in the string byte interval specified by
startandend. Returns zero if the key is missing as it is treated as an empty string. - See Also:
- valkey.io for details.
- Example:
Long payload = client.bitcount(gs("myKey1"), 1, 3).get(); assert payload == 2L; // The second to fourth bytes of the string stored at "myKey1" contains 2 set bits.
-
bitcount
java.util.concurrent.CompletableFuture<java.lang.Long> bitcount(java.lang.String key, long start, long end, BitmapIndexType options)Counts the number of set bits (population counting) in a string stored atkey. The offsetsstartandendare zero-based indexes, with0being the first element of the list,1being the next element and so on. These offsets can also be negative numbers indicating offsets starting at the end of the list, with-1being the last element of the list,-2being the penultimate, and so on.- Parameters:
key- The key for the string to count the set bits of.start- The starting offset.end- The ending offset.options- The index offset type. Could be eitherBitmapIndexType.BITorBitmapIndexType.BYTE.- Returns:
- The number of set bits in the string interval specified by
start,end, andoptions. Returns zero if the key is missing as it is treated as an empty string. - Since:
- Valkey 7.0 and above
- See Also:
- valkey.io for details.
- Example:
Long payload = client.bitcount("myKey1", 1, 1, BIT).get(); assert payload == 1L; // Indicates that the second bit of the string stored at "myKey1" is set.
-
bitcount
java.util.concurrent.CompletableFuture<java.lang.Long> bitcount(GlideString key, long start, long end, BitmapIndexType options)
Counts the number of set bits (population counting) in a string stored atkey. The offsetsstartandendare zero-based indexes, with0being the first element of the list,1being the next element and so on. These offsets can also be negative numbers indicating offsets starting at the end of the list, with-1being the last element of the list,-2being the penultimate, and so on.- Parameters:
key- The key for the string to count the set bits of.start- The starting offset.end- The ending offset.options- The index offset type. Could be eitherBitmapIndexType.BITorBitmapIndexType.BYTE.- Returns:
- The number of set bits in the string interval specified by
start,end, andoptions. Returns zero if the key is missing as it is treated as an empty string. - Since:
- Valkey 7.0 and above
- See Also:
- valkey.io for details.
- Example:
Long payload = client.bitcount(gs("myKey1"), 1, 1, BIT).get(); assert payload == 1L; // Indicates that the second bit of the string stored at "myKey1" is set.
-
setbit
java.util.concurrent.CompletableFuture<java.lang.Long> setbit(java.lang.String key, long offset, long value)Sets or clears the bit atoffsetin the string value stored atkey. Theoffsetis a zero-based index, with0being the first element of the list,1being the next element, and so on. Theoffsetmust be less than2^32and greater than or equal to0. If a key is non-existent then the bit atoffsetis set tovalueand the preceding bits are set to0.- Parameters:
key- The key of the string.offset- The index of the bit to be set.value- The bit value to set atoffset. The value must be0or1.- Returns:
- The bit value that was previously stored at
offset. - See Also:
- valkey.io for details.
- Example:
Long payload = client.setbit("myKey1", 1, 1).get(); assert payload == 0L; // The second bit value was 0 before setting to 1.
-
setbit
java.util.concurrent.CompletableFuture<java.lang.Long> setbit(GlideString key, long offset, long value)
Sets or clears the bit atoffsetin the string value stored atkey. Theoffsetis a zero-based index, with0being the first element of the list,1being the next element, and so on. Theoffsetmust be less than2^32and greater than or equal to0. If a key is non-existent then the bit atoffsetis set tovalueand the preceding bits are set to0.- Parameters:
key- The key of the string.offset- The index of the bit to be set.value- The bit value to set atoffset. The value must be0or1.- Returns:
- The bit value that was previously stored at
offset. - See Also:
- valkey.io for details.
- Example:
Long payload = client.setbit(gs("myKey1"), 1, 1).get(); assert payload == 0L; // The second bit value was 0 before setting to 1.
-
getbit
java.util.concurrent.CompletableFuture<java.lang.Long> getbit(java.lang.String key, long offset)Returns the bit value atoffsetin the string value stored atkey.offsetshould be greater than or equal to zero.- Parameters:
key- The key of the string.offset- The index of the bit to return.- Returns:
- The bit at offset of the string. Returns zero if the key is empty or if the positive
offsetexceeds the length of the string. - See Also:
- valkey.io for details.
- Example:
client.set("sampleKey", "A"); // "A" has binary value 01000001 Long payload = client.getbit("sampleKey", 1).get(); assert payload == 1L; // The second bit for string stored at "sampleKey" is set to 1.
-
getbit
java.util.concurrent.CompletableFuture<java.lang.Long> getbit(GlideString key, long offset)
Returns the bit value atoffsetin the string value stored atkey.offsetshould be greater than or equal to zero.- Parameters:
key- The key of the string.offset- The index of the bit to return.- Returns:
- The bit at offset of the string. Returns zero if the key is empty or if the positive
offsetexceeds the length of the string. - See Also:
- valkey.io for details.
- Example:
client.set(gs("sampleKey"), gs("A")); // "A" has binary value 01000001 Long payload = client.getbit(gs("sampleKey"), 1).get(); assert payload == 1L; // The second bit for string stored at "sampleKey" is set to 1.
-
bitpos
java.util.concurrent.CompletableFuture<java.lang.Long> bitpos(java.lang.String key, long bit)Returns the position of the first bit matching the givenbitvalue.- Parameters:
key- The key of the string.bit- The bit value to match. The value must be0or1.- Returns:
- The position of the first occurrence matching
bitin the binary value of the string held atkey. Ifbitis not found, a-1is returned. - See Also:
- valkey.io for details.
- Example:
Long payload = client.bitpos("myKey1", 0).get(); // Indicates that the first occurrence of a 0 bit value is the fourth bit of the binary value // of the string stored at "myKey1". assert payload == 3L;
-
bitpos
java.util.concurrent.CompletableFuture<java.lang.Long> bitpos(GlideString key, long bit)
Returns the position of the first bit matching the givenbitvalue.- Parameters:
key- The key of the string.bit- The bit value to match. The value must be0or1.- Returns:
- The position of the first occurrence matching
bitin the binary value of the string held atkey. Ifbitis not found, a-1is returned. - See Also:
- valkey.io for details.
- Example:
Long payload = client.bitpos(gs("myKey1"), 0).get(); // Indicates that the first occurrence of a 0 bit value is the fourth bit of the binary value // of the string stored at "myKey1". assert payload == 3L;
-
bitpos
java.util.concurrent.CompletableFuture<java.lang.Long> bitpos(java.lang.String key, long bit, long start)Returns the position of the first bit matching the givenbitvalue. The offsetstartis a zero-based index, with0being the first byte of the list,1being the next byte and so on. These offsets can also be negative numbers indicating offsets starting at the end of the list, with-1being the last byte of the list,-2being the penultimate, and so on.- Parameters:
key- The key of the string.bit- The bit value to match. The value must be0or1.start- The starting offset.- Returns:
- The position of the first occurrence beginning at the
startoffset of thebitin the binary value of the string held atkey. Ifbitis not found, a-1is returned. - See Also:
- valkey.io for details.
- Example:
Long payload = client.bitpos("myKey1", 1, 4).get(); // Indicates that the first occurrence of a 1 bit value starting from fifth byte is the 34th // bit of the binary value of the string stored at "myKey1". assert payload == 33L;
-
bitpos
java.util.concurrent.CompletableFuture<java.lang.Long> bitpos(GlideString key, long bit, long start)
Returns the position of the first bit matching the givenbitvalue. The offsetstartis a zero-based index, with0being the first byte of the list,1being the next byte and so on. These offsets can also be negative numbers indicating offsets starting at the end of the list, with-1being the last byte of the list,-2being the penultimate, and so on.- Parameters:
key- The key of the string.bit- The bit value to match. The value must be0or1.start- The starting offset.- Returns:
- The position of the first occurrence beginning at the
startoffset of thebitin the binary value of the string held atkey. Ifbitis not found, a-1is returned. - See Also:
- valkey.io for details.
- Example:
Long payload = client.bitpos(gs("myKey1"), 1, 4).get(); // Indicates that the first occurrence of a 1 bit value starting from fifth byte is the 34th // bit of the binary value of the string stored at "myKey1". assert payload == 33L;
-
bitpos
java.util.concurrent.CompletableFuture<java.lang.Long> bitpos(java.lang.String key, long bit, long start, long end)Returns the position of the first bit matching the givenbitvalue. The offsetsstartandendare zero-based indexes, with0being the first byte of the list,1being the next byte and so on. These offsets can also be negative numbers indicating offsets starting at the end of the list, with-1being the last byte of the list,-2being the penultimate, and so on.- Parameters:
key- The key of the string.bit- The bit value to match. The value must be0or1.start- The starting offset.end- The ending offset.- Returns:
- The position of the first occurrence from the
startto theendoffsets of thebitin the binary value of the string held atkey. Ifbitis not found, a-1is returned. - See Also:
- valkey.io for details.
- Example:
Long payload = client.bitpos("myKey1", 1, 4, 6).get(); // Indicates that the first occurrence of a 1 bit value starting from the fifth to seventh // bytes is the 34th bit of the binary value of the string stored at "myKey1". assert payload == 33L;
-
bitpos
java.util.concurrent.CompletableFuture<java.lang.Long> bitpos(GlideString key, long bit, long start, long end)
Returns the position of the first bit matching the givenbitvalue. The offsetsstartandendare zero-based indexes, with0being the first byte of the list,1being the next byte and so on. These offsets can also be negative numbers indicating offsets starting at the end of the list, with-1being the last byte of the list,-2being the penultimate, and so on.- Parameters:
key- The key of the string.bit- The bit value to match. The value must be0or1.start- The starting offset.end- The ending offset.- Returns:
- The position of the first occurrence from the
startto theendoffsets of thebitin the binary value of the string held atkey. Ifbitis not found, a-1is returned. - See Also:
- valkey.io for details.
- Example:
Long payload = client.bitpos(gs("myKey1"), 1, 4, 6).get(); // Indicates that the first occurrence of a 1 bit value starting from the fifth to seventh // bytes is the 34th bit of the binary value of the string stored at "myKey1". assert payload == 33L;
-
bitpos
java.util.concurrent.CompletableFuture<java.lang.Long> bitpos(java.lang.String key, long bit, long start, long end, BitmapIndexType offsetType)Returns the position of the first bit matching the givenbitvalue. The offsetoffsetTypespecifies whether the offset is a BIT or BYTE. If BIT is specified,start==0andend==2means to look at the first three bits. If BYTE is specified,start==0andend==2means to look at the first three bytes The offsets are zero-based indexes, with0being the first element of the list,1being the next, and so on. These offsets can also be negative numbers indicating offsets starting at the end of the list, with-1being the last element of the list,-2being the penultimate, and so on.- Parameters:
key- The key of the string.bit- The bit value to match. The value must be0or1.start- The starting offset.end- The ending offset.offsetType- The index offset type. Could be eitherBitmapIndexType.BITorBitmapIndexType.BYTE.- Returns:
- The position of the first occurrence from the
startto theendoffsets of thebitin the binary value of the string held atkey. Ifbitis not found, a-1is returned. - Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for details.
- Example:
Long payload = client.bitpos("myKey1", 1, 4, 6, BIT).get(); // Indicates that the first occurrence of a 1 bit value starting from the fifth to seventh // bits is the sixth bit of the binary value of the string stored at "myKey1". assert payload == 5L;
-
bitpos
java.util.concurrent.CompletableFuture<java.lang.Long> bitpos(GlideString key, long bit, long start, long end, BitmapIndexType offsetType)
Returns the position of the first bit matching the givenbitvalue. The offsetoffsetTypespecifies whether the offset is a BIT or BYTE. If BIT is specified,start==0andend==2means to look at the first three bits. If BYTE is specified,start==0andend==2means to look at the first three bytes The offsets are zero-based indexes, with0being the first element of the list,1being the next, and so on. These offsets can also be negative numbers indicating offsets starting at the end of the list, with-1being the last element of the list,-2being the penultimate, and so on.- Parameters:
key- The key of the string.bit- The bit value to match. The value must be0or1.start- The starting offset.end- The ending offset.offsetType- The index offset type. Could be eitherBitmapIndexType.BITorBitmapIndexType.BYTE.- Returns:
- The position of the first occurrence from the
startto theendoffsets of thebitin the binary value of the string held atkey. Ifbitis not found, a-1is returned. - Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for details.
- Example:
Long payload = client.bitpos(gs("myKey1"), 1, 4, 6, BIT).get(); // Indicates that the first occurrence of a 1 bit value starting from the fifth to seventh // bits is the sixth bit of the binary value of the string stored at "myKey1". assert payload == 5L;
-
bitop
java.util.concurrent.CompletableFuture<java.lang.Long> bitop(BitwiseOperation bitwiseOperation, java.lang.String destination, java.lang.String[] keys)
Perform a bitwise operation between multiple keys (containing string values) and store the result in thedestination.- Parameters:
bitwiseOperation- The bitwise operation to perform.destination- The key that will store the resulting string.keys- The list of keys to perform the bitwise operation on.- Returns:
- The size of the string stored in
destination. - See Also:
- valkey.io for details.
- Example:
client.set("key1", "A"); // "A" has binary value 01000001 client.set("key2", "B"); // "B" has binary value 01000010 Long payload = client.bitop(BitwiseOperation.AND, "destination", new String[] {key1, key2}).get(); assert "@".equals(client.get("destination").get()); // "@" has binary value 01000000 assert payload == 1L; // The size of the resulting string is 1.
-
bitop
java.util.concurrent.CompletableFuture<java.lang.Long> bitop(BitwiseOperation bitwiseOperation, GlideString destination, GlideString[] keys)
Perform a bitwise operation between multiple keys (containing string values) and store the result in thedestination.- Parameters:
bitwiseOperation- The bitwise operation to perform.destination- The key that will store the resulting string.keys- The list of keys to perform the bitwise operation on.- Returns:
- The size of the string stored in
destination. - See Also:
- valkey.io for details.
- Example:
client.set("key1", "A"); // "A" has binary value 01000001 client.set("key2", "B"); // "B" has binary value 01000010 Long payload = client.bitop(BitwiseOperation.AND, gs("destination"), new GlideString[] {key1, key2}).get(); assert "@".equals(client.get("destination").get()); // "@" has binary value 01000000 assert payload == 1L; // The size of the resulting string is 1.
-
bitfield
java.util.concurrent.CompletableFuture<java.lang.Long[]> bitfield(java.lang.String key, BitFieldOptions.BitFieldSubCommands[] subCommands)Reads or modifies the array of bits representing the string that is held atkeybased on the specifiedsubCommands.- Parameters:
key- The key of the string.subCommands- The subCommands to be performed on the binary value of the string atkey, which could be any of the following:- Returns:
- An
arrayof results from the executed subcommands.BitFieldOptions.BitFieldGetreturns the value inBitFieldOptions.OffsetorBitFieldOptions.OffsetMultiplier.BitFieldOptions.BitFieldSetreturns the old value inBitFieldOptions.OffsetorBitFieldOptions.OffsetMultiplier.BitFieldOptions.BitFieldIncrbyreturns the new value inBitFieldOptions.OffsetorBitFieldOptions.OffsetMultiplier.BitFieldOptions.BitFieldOverflowdetermines the behaviour ofSETandINCRBYwhen an overflow occurs.OVERFLOWdoes not return a value and does not contribute a value to the array response.
- See Also:
- valkey.io for details.
- Example:
client.set("sampleKey", "A"); // "A" has binary value 01000001 BitFieldSubCommands[] subcommands = new BitFieldSubCommands[] { new BitFieldSet(new UnsignedEncoding(2), new Offset(1), 3), // Sets the new binary value to 01100001 new BitFieldGet(new UnsignedEncoding(2), new Offset(1)) // Gets value from 0(11)00001 }; Long[] payload = client.bitfield("sampleKey", subcommands).get(); assertArrayEquals(payload, new Long[] {2L, 3L});
-
bitfield
java.util.concurrent.CompletableFuture<java.lang.Long[]> bitfield(GlideString key, BitFieldOptions.BitFieldSubCommands[] subCommands)
Reads or modifies the array of bits representing the string that is held atkeybased on the specifiedsubCommands.- Parameters:
key- The key of the string.subCommands- The subCommands to be performed on the binary value of the string atkey, which could be any of the following:- Returns:
- An
arrayof results from the executed subcommands.BitFieldOptions.BitFieldGetreturns the value inBitFieldOptions.OffsetorBitFieldOptions.OffsetMultiplier.BitFieldOptions.BitFieldSetreturns the old value inBitFieldOptions.OffsetorBitFieldOptions.OffsetMultiplier.BitFieldOptions.BitFieldIncrbyreturns the new value inBitFieldOptions.OffsetorBitFieldOptions.OffsetMultiplier.BitFieldOptions.BitFieldOverflowdetermines the behaviour ofSETandINCRBYwhen an overflow occurs.OVERFLOWdoes not return a value and does not contribute a value to the array response.
- See Also:
- valkey.io for details.
- Example:
client.set(gs("sampleKey"), gs("A")); // string "A" has binary value 01000001 BitFieldSubCommands[] subcommands = new BitFieldSubCommands[] { new BitFieldSet(new UnsignedEncoding(2), new Offset(1), 3), // Sets the new binary value to 01100001 new BitFieldGet(new UnsignedEncoding(2), new Offset(1)) // Gets value from 0(11)00001 }; Long[] payload = client.bitfield(gs("sampleKey"), subcommands).get(); assertArrayEquals(payload, new Long[] {2L, 3L});
-
bitfieldReadOnly
java.util.concurrent.CompletableFuture<java.lang.Long[]> bitfieldReadOnly(java.lang.String key, BitFieldOptions.BitFieldReadOnlySubCommands[] subCommands)Reads the array of bits representing the string that is held atkeybased on the specifiedsubCommands.
This command is routed depending on the client'sReadFromstrategy.- Parameters:
key- The key of the string.subCommands- TheGETsubCommands to be performed.- Returns:
- An array of results from the
GETsubcommands. - Since:
- Valkey 6.0 and above
- See Also:
- valkey.io for details.
- Example:
client.set("sampleKey", "A"); // "A" has binary value 01000001 Long[] payload = client. bitfieldReadOnly( "sampleKey", new BitFieldReadOnlySubCommands[] { new BitFieldGet(new UnsignedEncoding(2), new Offset(1)) }) .get(); assertArrayEquals(payload, new Long[] {2L}); // Value is from 0(10)00001
-
bitfieldReadOnly
java.util.concurrent.CompletableFuture<java.lang.Long[]> bitfieldReadOnly(GlideString key, BitFieldOptions.BitFieldReadOnlySubCommands[] subCommands)
Reads the array of bits representing the string that is held atkeybased on the specifiedsubCommands.
This command is routed depending on the client'sReadFromstrategy.- Parameters:
key- The key of the string.subCommands- TheGETsubCommands to be performed.- Returns:
- An array of results from the
GETsubcommands. - Since:
- Valkey 6.0 and above
- See Also:
- valkey.io for details.
- Example:
client.set(gs("sampleKey"), gs("A")); //string "A" has binary value 01000001 Long[] payload = client. bitfieldReadOnly( gs("sampleKey"), new BitFieldReadOnlySubCommands[] { new BitFieldGet(new UnsignedEncoding(2), new Offset(1)) }) .get(); assertArrayEquals(payload, new Long[] {2L}); // Value is from 0(10)00001
-
-