Redis Learning Note – 04 Command in Redis (String)
In Readis, STRINGs are used to store three types of values:
- Byte string value.
- Integer value.
- Floating-point value.
Integers and floars can be incremented or decremented by an arbitary numeric value (integers turning into floats as necessary).
INCRBYFLOAT key increment
Increment the float value of a key by the given amount. If the key does not exist, it is set to 0 before performing the operation. An error is returned if one of the following conditions occur:
- The key contains a value of the wrong type (not a string).
- The current key content or the specified increment are not parsable as a double precision floating point number.
Append 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 SET in this special case.
Get a substring of the string stored at a key. 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.
Overwrite part of a string at key starting at the specified offset. 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. Non-existing keys are considered as empty strings, so this command will make sure it holds a string large enough to be able to set value at offset.
Note that the maximum offset that you can set is 229 -1 (536870911), as Redis Strings are limited to 512 megabytes. If you need to grow beyond this size, you can use multiple keys.
Note that once this first allocation is done, subsequent calls to SETRANGE for the same key will not have the allocation overhead.
Count set bits in a string. Non-existent keys are treated as empty strings, so the command will return zero.
Perform a bitwise operation between multiple keys (containing string values) and store the result in the destination key.
- BITOP AND destkey srckey1 srckey2 srckey3 … srckeyN
- BITOP OR destkey srckey1 srckey2 srckey3 … srckeyN
- BITOP XOR destkey srckey1 srckey2 srckey3 … srckeyN
- BITOP NOT destkey srckey