Interface BitCommands

All Known Subinterfaces:
JedisCommands, StringCommands
All Known Implementing Classes:
Jedis, JedisCluster, JedisPooled, JedisSentineled, JedisSharding, UnifiedJedis

public interface BitCommands
  • Method Details

    • setbit

      boolean setbit(String key, long offset, boolean value)
      SetBit Command Sets or clears the bit at offset in the string value stored at key.

      Time complexity: O(1)

      Parameters:
      key -
      offset -
      value -
      Returns:
      The original bit value stored at offset
    • getbit

      boolean getbit(String key, long offset)
      GetBit Command Returns the bit value at offset in the string value stored at key.

      Time complexity: O(1)

      Parameters:
      key -
      offset -
      Returns:
      The bit value stored at offset
    • bitcount

      long bitcount(String key)
      Bitcount Command Count the number of set bits (population counting) in a string.
      Parameters:
      key -
      Returns:
      The number of bits set to 1
    • bitcount

      long bitcount(String key, long start, long end)
      Bitcount Command Count the number of set bits (population counting) in a string only in an interval start and end.

      Like for the GETRANGE command start and end can contain negative values in order to index bytes starting from the end of the string, where -1 is the last byte, -2 is the penultimate, and so forth.

      Parameters:
      key -
      start - byte start index
      end - byte end index
      Returns:
      The number of bits set to 1
    • bitcount

      long bitcount(String key, long start, long end, BitCountOption option)
      Parameters:
      key -
      start - byte start index
      end - byte end index
      option - indicate BYTE or BIT
      Returns:
      The number of bits set to 1
      See Also:
    • bitpos

      long bitpos(String key, boolean value)
      Bitpos Command Return the position of the first bit set to 1 or 0 in a string.
      Parameters:
      key -
      value - the bit value
      Returns:
      The position of the first bit set to 1 or 0 according to the request
    • bitpos

      long bitpos(String key, boolean value, BitPosParams params)
      Bitpos Command Return the position of the first bit set to 1 or 0 in a string.
      Parameters:
      key -
      value - the bit value
      params - BitPosParams
      Returns:
      The position of the first bit set to 1 or 0 according to the request
    • bitfield

      List<Long> bitfield(String key, String... arguments)
      Bitfield Command The command treats a Redis string as an array of bits, and is capable of addressing specific integer fields of varying bit widths and arbitrary non (necessary) aligned offset.
      Parameters:
      key -
      arguments - may be used with optional arguments
      Returns:
      A List of results
    • bitfieldReadonly

      List<Long> bitfieldReadonly(String key, String... arguments)
      The readonly version of BITFIELD
    • bitop

      long bitop(BitOP op, String destKey, String... srcKeys)
      Bitop Command Perform a bitwise operation between multiple keys (containing string values) and store the result in the destKey.
      Parameters:
      op - can be AND, OR, XOR or NOT
      destKey -
      srcKeys -
      Returns:
      The size of the string stored in the destKey