| Command prototypes |
Complexity of Time |
Command description |
return value |
| APPENDKeyValue |
O (1) |
If the key already exists, the append command appends the data for the parameter value to the end of the existing value. If the key does not exist, the append command will create a new key/value. |
The length of the value after append. |
| DECRKey |
O (1) |
Decrements the value of the specified key by 1. If the key does not exist, its initial value is 0, and after decr its value is-1. If the value of value cannot be converted to an integer value, such as Hello, the operation fails and returns the appropriate error message. Note: The value range for this operation is a 64-bit signed integer. |
The value after the decrement. |
| INCRKey |
O (1) |
Increments the value of the specified key by 1. If the key does not exist, its initial value is 0, and after incr its value is 1. If the value of value cannot be converted to an integer value, such as Hello, the operation fails and returns the appropriate error message. Note: The value range for this operation is a 64-bit signed integer. |
The value after increment. |
| DecrbyKey Decrement |
O (1) |
The value of the specified key is reduced by decrement. If the key does not exist, its initial value is 0, and after decrby its value is-decrement. If the value of value cannot be converted to an integer value, such as Hello, the operation fails and returns the appropriate error message. Note: The value range for this operation is a 64-bit signed integer. |
The value after the decrease. |
| IncrbyKey increment |
O (1) |
Adds the value atomicity of the specified key to increment. If the key does not exist, its initial value is 0, and after incrby its value is increment. If the value of value cannot be converted to an integer value, such as Hello, the operation fails and returns the appropriate error message. Note: The value range for this operation is a 64-bit signed integer. |
The value after the increment. |
| GETKey |
O (1) |
Gets the value of the specified key. If the Value associated with the key is not of type string, Redis returns an error message because the GET command can only be used to get string Value. |
The value associated with the key, if the key does not exist, returns nil. |
| SETKey value |
O (1) |
Sets the key to hold the specified string value, overwriting its original value if the key already exists. |
Always return "OK". |
| getsetKey value |
O (1) |
The atomic setting of the key is the specified value, and the original values of the key are returned. As with the Get command, the command can handle only string Value, or Redis will give you a related error message. |
Returns the original value of the key, or nil if the key does not exist before. |
| STRLENKey |
O (1) |
Returns the length of the character value for the specified key, and if value is not of type string, Redis will fail and give the associated error message. |
Returns the value character length of the specified key, or 0 if the key does not exist. |
| SetexKey seconds value |
O (1) |
Atomicity completes two operations, one is to set the value of the key to the specified string, and set the key in the Redis server survival time (in seconds). This command is primarily used when Redis is used as a cache server. |
|
| setnxKey value |
O (1) |
If the specified key does not exist, the key is set to hold the specified string value, at which point the effect is equivalent to the SET command. Conversely, if the key already exists, the command will not take any action and return. |
1 indicates that the setting was successful, otherwise 0. |
| SETRANGEKey offset value |
O (1) |
Replaces the partial string value of the specified key. Starting with offset, the length of the replacement is the string length of the third parameter of the command value, where if the value of offset is greater than the string length of the original value of the key, Redis will be padded with value (Offset-strlen (value)) The number of 0x00, and then append the new value. If the key does not exist, the command assumes the length of its original value as 0, and then appends a new value after fill offset 0x00. Since the maximum length of string value is 512M, the maximum value for offset is 536870911. Finally, it is important to note that if the command is executed with an increase in the length of the original value of the specified key, it will cause Redis to reallocate enough memory to accommodate all of the replaced strings, resulting in some performance impairment. |
The modified string value length. |
| GETRANGEKey Start end |
O (1) |
If the truncated string is short, we can consider the time complexity of the command as O (1), or O (n), where n represents the length of the truncated substring. When the substring is truncated, the command will contain both start (0 for first character) and end character in a closed interval, and if the end value exceeds the character length of value, the command will simply intercept all character data after start. |
Sub-string |
| setbitKey offset value |
O (1) |
Sets the value of bit on the specified offset, which can only be 1 or 0, after which the command returns the original bit value on that offset. If the specified key does not exist, the command creates a new value and sets the bit value in the parameter on the specified offset. If offset is greater than the character length of value, Redis will lengthen the value and set the bit value in the parameter on the specified offset, and the bit value added in the middle is 0. Finally, it should be stated that the value of offset must be greater than 0. |
The bit original value on the specified offset. |
| getbitKey offset |
O (1) |
Returns the value of bit on the specified offset, 0 or 1. If offset exceeds the length of string value, the command returns 0, so always returns 0 for an empty string. |
The bit value on the specified offset. |
| MGETkey [key ...] |
O (N) |
n indicates the number of keys to get. Returns all values of the specified keys, if one of them does not exist, or if the value is not of type string, the key's value returns nil. |
Returns a list of values for the specified keys. |
| MSETkey value [key value ...] |
O (N) |
n indicates the number of keys specified. The command atomically completes the set operation of all key/value in the parameter, and its specific behavior can be seen as executing the SET command multiple iterations. |
The command does not fail and always returns OK. |
| msetnxkey value [key value ...] |
O (N) |
n indicates the number of keys specified. The command atomically completes the set operation of all key/value in the parameter, and its specific behavior can be seen as multiple iterations of the execution of the SETNX command. However, it is necessary to make it clear that if any of the keys in this batch are already present, the operation will all be rolled back, that is, all modifications will not take effect. |
1 means all keys are set successfully, and 0 means no key is modified. |