command prototype |
Time complexity |
command description |
return value |
hset key field value |
O (1) |
Sets the field/value pair for the specified key, and if key does not exist, the command creates a new key with the field/value pair in the argument, overwriting its original value with the new value if the field in the argument already exists in the key. |
1 indicates that the new field is set with a new value, 0 indicates that field already exists, and overwrites the original value with the new value. |
hget key field |
O (1) |
Returns the associated value for the specified field in the specified key. |
Returns the associated value of field in the parameter, or nil if the key or field in the argument does not exist. |
hexists key field |
O (1) |
Determines whether the specified field in the specified key exists. |
1 is present, and 0 indicates that the field or key in the parameter does not exist. |
Hlen Key |
O (1) |
Gets the number of field that the key contains. |
Returns the number of field keys contained in the key, or 0 if key does not exist. |
hdel key field [field ...] |
O (N) |
N In time complexity indicates the number of fields to be deleted in the parameter. Removes the multiple fields specified in the parameter from hashes value of the specified key if the nonexistent field is ignored. If the key does not exist, it is treated as an empty hashes and returns 0. |
The number of field actually deleted. |
hsetnx key field value |
O (1) |
A Field/value pair is set for the specified key only if the key or field in the argument does not exist, otherwise the command will not do anything. |
1 indicates that the new field is set to a new value, and 0 indicates that the key or field already exists and that the command does nothing. |
hincrby key field increment |
O (1) |
Increments the value of value that is associated with the specified field in the specified key. If the key or field does not exist, the command creates a new key or a new field, initializes its associated value to 0, and then specifies the operation to increment the number. The number supported by this command is a 64-bit signed integer, which means that increment can be negative. |
Returns the value after the operation. |
Hgetall Key |
O (N) |
N In time complexity indicates the number of field numbers that key contains. Gets all the field/value that the key contains. Its return format is a field, a value, and so on. |
A list of field/value. |
Hkeys Key |
O (N) |
N In time complexity indicates the number of field numbers that key contains. Returns all fields names for the specified key. |
A list of field. |
hvals Key |
O (N) |
N In time complexity indicates the number of field numbers that key contains. Returns all the values for the specified key. |
The list of value. |
hmget key field [field ...] |
O (N) |
N In time complexity indicates the number of field requests. Gets a set of values that is associated with the fields specified in the parameter. If the requested field does not exist, its value returns nil. If key does not exist, the command treats it as an empty hash and returns a set of nil. |
Returns and requests a set of values that are associated with a fields, whose return order is equivalent to the order of fields in the request. |
hmset key field value [field value ...] |
O (N) |
N in time complexity indicates the number of field sets that are set. Set the Field/value pairs given in the parameters on a per-pair basis. If one of the field already exists, the original value is overwritten with the new value. If key does not exist, create a new key and set the Field/value in the parameter. |
|