English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
Redis hash is a mapping table of string type field (field) and value (value), which is especially suitable for storing objects.
Each hash in Redis can store 232 - 1 Key-value pair (40 billion).
127.0.0.1:6379> HMSET w3codeboxkey name "redis tutorial" description "redis basic commands for caching" likes 20 visitors 23000 OK 127.0.0.1:6379> HGETALL w3codeboxkey 1) "name" 2) "redis tutorial" 3) "description" 4) "redis basic commands for caching" 5) "likes" 6) "20" 7) "visitors" 8) "23000"
In the above examples, we set some description information (name, description, likes, visitors) of redis to the hash table of w3codeboxkey In.
The following table lists the basic Redis hash related commands:
Serial number | Command and description |
---|---|
1 | HDEL key field1 [field2] Delete one or more hash table fields |
2 | HEXISTS key field Check if the specified field exists in the hash table key. |
3 | HGET key field Get the value of the specified field stored in the hash table. |
4 | HGETALL key Get all fields and values of the specified key in the hash table. |
5 | HINCRBY key field increment Add an increment to the integer value of the specified field in the hash table key. |
6 | HINCRBYFLOAT key field increment Add an increment to the floating-point value of the specified field in the hash table key. |
7 | HKEYS key Get all fields in all hash tables. |
8 | HLEN key Get the number of fields in a hash table. |
9 | HMGET key field1 [field2] Get the values of all given fields. |
10 | HMSET key field1 value1 [field2 value2 ] Set multiple field-value (domain-Set the key-value pair to the hash table key. |
11 | HSET key field value Set the value of the field field in the hash table key to value. |
12 | HSETNX key field value Set the value of a hash table field only if the field does not exist. |
13 | HVALS key Get all values in a hash table. |
14 | HSCAN key cursor [MATCH pattern] [COUNT count] Iterate over key-value pairs in a hash table. |
For more commands, please refer to:https://redis.io/commands