redis binary string type key operation

  • Command name: setbit
  • Syntax: setbit key offset value
  • Function: 1) of the key string stored value, set or clear the bits (bit) on the specified offset parameter value set or clear depending on the position, may be 0 or may be 1.2) strings for stretching (grown) to ensure that it can be stored in the value specified offset. When the extended string value, empty space filled with 0. offset must be greater than or equal to 0 and less than 2 ^ 32 (bit maps is restricted within the 512MB)
  • Return value: 1) when the key is not present, automatically generates a new string value. 2) Specify the original stored bit offset.

 

  • Command name: getbit
  • Syntax: getbit key offset
  • Function: 1) the value of the key string stored acquires bit (bit at the specified offset)
  • Return Value: 1) When the offset value is larger than the length of the string, or the key does not exist, it returns 0.2) on the bit string offset value (bit)

 

  • Command name: bitcount
  • Syntax: bitcount key [start] [end]
  • Note: start and end is a byte, a byte is 8 bits
  • Function: 1) is calculated in the given string, the number of bits is set to 1. 2) In general, given the entire string will be counted, by specifying the start or end of additional parameters, allowing counting only in a specific position.
  • Return Value: 1) the key is not present as an empty string is processed, so the key for a non-existent bitcount operation, the result is 0/1 bit is set to the number

 

  • Command name: bitop
  • 语法:bitop operation destkey key [key……]
  • Function: 1) one or more binary bits stored bit string for key operation and save the result to the destkey.
  • OPERATION: 1) and may be (and), or (or), Not (non), any one of xor (exclusive OR) of the four operations. 2) In addition to not operate, other operations can accept as input one or more key
  • Note: 1) When the processing bitop different string lengths, the shorter of the frontal part of the missing character string is regarded as 0. The key blank may also be viewed as comprising a sequence of characters 0
  • Return Value: 1) to save the length of the string destkey equal to the input key and the longest string length.

 

  • Command name: bitpos
  • Syntax: bitpos key bit [start] [end]
  • Note: start and end is a byte, a byte is 8 bits
  • Function: 1) Returns a string inside the first bit is set to 0 or 1 bit.
  • Return Value: 1) returns the string inside the first bit is set to 0 or 1 bit. 2) If we find an empty string or bit string which is the 0 byte of the content 1, the result returns -1.

Guess you like

Origin www.cnblogs.com/lxhyty/p/11364557.html