Redis command o...login
Redis command operation Chinese manual
author:php.cn  update time:2022-04-12 14:07:28

Redis Hash


Redis hash is a mapping table of string type fields and values. Hash is particularly suitable for storing objects.

Each hash in Redis can store 232 - 1 key-value pairs (more than 4 billion).

Example

redis 127.0.0.1:6379> HMSET w3ckey name "redis tutorial" description "redis basic commands for caching" likes 20 visitors 23000
OK
redis 127.0.0.1:6379> HGETALL w3ckey

1) "name"
2) "redis tutorial"
3) "description"
4) "redis basic commands for caching"
5) "likes"
6) "20"
7) "visitors"
8) "23000"

In the above example, we set some description information of redis (name, description, likes, visitors) to the w3ckey of the hash table.


Redis hash command

The following table lists the basic related commands of redis hash:

##5 HINCRBY key field increment 6HINCRBYFLOAT key field increment 7HKEYS key 8HLEN key 9HMGET key field1 [field2] 10HMSET key field1 value1 [field2 value2 ] 11HSET key field value 12HSETNX key field value 13HVALS key 14 HSCAN key cursor [MATCH pattern] [COUNT count]
Serial numberCommand and description
1HDEL key field2 [field2]
Delete one or more hash table fields
2HEXISTS key field
Check whether the specified field exists in the hash table key.
3HGET key field
Get the value of the specified field stored in the hash table.
4HGETALL key
Get all fields and values ​​of the specified key in the hash table
Add increment to the integer value of the specified field in the hash table key.
Add increment to the floating point value of the specified field in the hash table key.
Get all fields in the hash table
Get the number of fields in the hash table
Get the values ​​of all given fields
Set multiple field-value (field-value) pairs into the hash table key at the same time.
Set the value of field field in hash table key to value.
Set the value of the hash table field only when the field field does not exist.
Get all values ​​in the hash table
Iterate over the key-value pairs in the hash table.
For more commands, please refer to: http://redis.readthedocs.org/en/latest/