Command Prototypes |
Complexity of Time |
Command Description |
return value |
APPENDKeyValue |
O (1) |
If the key already exists, the append command appends the data of the parameter value to the end of the existing value. If the key does not exist, the append command creates a new key/value. |
The length of the appended value. |
DECRKey |
O (1) |
Decrements the value atomicity of the specified key by 1. If the key does not exist, its initial value is 0, and the value is-1 after DECR. If value cannot be converted to an integer value, such as Hello, the operation will fail and return the appropriate error message. Note: This operation is scoped to a 64-bit signed integer. |
The decremented value. |
INCRKey |
O (1) |
Increments the value atomicity of the specified key by 1. If the key does not exist, its initial value is 0, and the value is 1 after incr. If value cannot be converted to an integer value, such as Hello, the operation will fail and return the appropriate error message. Note: This operation is scoped to a 64-bit signed integer. |
The incremented value. |
DecrbyKey Decrement |
O (1) |
Decrement the reduction of the value atomicity of the specified key. If the key does not exist, its initial value is 0, and its value is-decrement after Decrby. If value cannot be converted to an integer value, such as Hello, the operation will fail and return the appropriate error message. Note: This operation is scoped to a 64-bit signed integer. |
The reduced value. |
IncrbyKey increment |
O (1) |
Adds the value atomicity of the specified key to the increment. If the key does not exist, its initial value is 0, and its value is increment after Incrby. If value cannot be converted to an integer value, such as Hello, the operation will fail and return the appropriate error message. Note: This operation is scoped to a 64-bit signed integer. |
The value of the increment. |
Get key |
O (1) |
Gets the value of the specified key. If the Value associated with this key is not a string type, Redis returns an error message because the GET command can only be used to obtain string Value. |
Value associated with the key, and returns nil if the key does not exist. |
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 value of the key is returned. As with the Get command, the command can only handle string Value, otherwise Redis will give the associated error message. |
Returns the original value of the key, and returns nil if the key does not exist before. |
STRLENKey |
O (1) |
Returns the length of the character value of the specified key, and if value is not a string type, Redis executes the failure and gives 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 accomplishes two things, one is to set the value of the key to the specified string, and to set the number of seconds that the key survives in the Redis server. 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, and the effect is equivalent to the SET command. Conversely, if the key already exists, the command does nothing and returns. |
1 indicates that the setting is successful or 0. |
SETRANGEKey offset value |
O (1) |
Replaces a partial string value for the specified key. Beginning with offset, the length of the replacement is the string length of the third parameter value of the command, where the value of offset is greater than the string length of the value of the key, Redis will be padded after value (Offset-strlen (value)) 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 the offset 0x00 to append the new value. 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 causes the value of the specified key to increase in length when executed, this will cause the Redis to reallocate enough memory to accommodate all the replaced strings, thereby causing some performance impairment. |
The modified string value length. |
getrangeKey Start end |
O (1) |
If the length of the intercepted string is very short, we can see the time complexity of the command as O (1), or O (n), where N denotes the length of the intercepted substring. When the substring is intercepted, the command will contain both the start (0 for the first character) and the end of the string in a closed interval, and if the end value exceeds the character length of value, the command will simply intercept all character data from the beginning of start. |
Substring |
setbitKey offset value |
O (1) |
Sets the value of the bit on the specified offset, which can only be 1 or 0, and returns the original bit value on the offset upon setting. 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 the 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, with the bit value added in the middle being 0. The last thing to note is that the offset value must be greater than 0. |
The bit original value on the specified offset. |
getbitKey offset |
O (1) |
Returns the value of the 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 values for all specified keys, if one of the key does not exist, or if its value is not a string type, the value of the key returns to nil. |
Returns a list of values for the specified keys. |
msetkey value [key value ...] |
O (N) |
n indicates the number of key specified. All key/value in the completion parameters of the command atomicity are set up, and their specific behavior can be seen as multiple iterations to execute the SET command. |
This command does not fail and always returns OK. |
msetnxkey value [key value ...] |
O (N) |
n indicates the number of key specified. All key/value in the completion parameters of the command atomicity are set up, and their specific behavior can be seen as multiple iterations to execute the setnx command. What needs to be made clear here, however, is that if any key in the keys already exists, the operation will be rolled back, that is, all modifications will not take effect. |
1 indicates that all keys are set successfully, and 0 indicates that no key has been modified. |