English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Redis Hashes (Hash)

Redis hash ist ein Mapping von String-Typen (Feld) und (Wert), das besonders gut für die Speicherung von Objekten geeignet ist.

Jeder Hash in Redis kann mehrere Schlüssel-Wert-Paare speichern 232 - 1 Schlüssel-Wert-Paar (40 mehr als Milliarden).

Online-Beispiel

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 den obigen Beispielen haben wir einige Beschreibungen von Redis (name, description, likes, visitors) in den Hash-Tabelle w3codeboxkey dargestellt.

Redis-Hash-Befehle

Die folgende Tabelle zeigt die grundlegenden Redis-Hash-Befehle:

NummerBefehl und Beschreibung
1HDEL key field1 [field2]
Löschen Sie ein oder mehrere Felder der Hash-Tabelle
2HEXISTS key field
Überprüfen Sie, ob das angegebene Feld in der Hash-Tabelle key existiert.
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.
5HINCRBY key field increment
Add an increment to the integer value of the specified field in the hash table key.
6HINCRBYFLOAT key field increment
Add an increment to the floating-point value of the specified field in the hash table key.
7HKEYS key
Get all fields in all hash tables.
8HLEN key
Get the number of fields in the hash table.
9HMGET key field1 [field2]
Get the values of all specified fields.
10HMSET key field1 value1 [field2 value2 ]
Set multiple field-value (domain-Set the key-value pair to the hash table key.
11HSET key field value
Set the value of the field field in the hash table key to value.
12HSETNX key field value
Set the value of the hash table field only if the field does not exist.
13HVALS key
Get all values in the hash table.
14HSCAN 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