Latest web development tutorials

comando Redis Hset

Redis hash (hash)

Redis comando Hset viene utilizzato per hash tabella di assegnazione campo.

Se la tabella di hash non esiste, una nuova tabella hash viene creato e il funzionamento HSET.

Se il campo esiste già nella tabella hash, il valore precedente verrà sovrascritto.

grammatica

Redis Hset sintassi dei comandi di base è la seguente:

redis 127.0.0.1:6379> HSET KEY_NAME FIELD VALUE 

versioni disponibili

> = 2.0.0

Valore di ritorno

Se il campo è nella tabella hash un nuovo campo, e impostare il valore del successo, 1 viene restituito. Se la tabella di hash esiste già nel campo di dominio e il vecchio valore viene sovrascritto con il nuovo valore, restituire 0.

Esempi

redis 127.0.0.1:6379> HSET myhash field1 "foo"
OK
redis 127.0.0.1:6379> HGET myhash field1
"foo"

redis 127.0.0.1:6379> HSET website google "www.g.cn"       # 设置一个新域
(integer) 1

redis 127.0.0.1:6379>HSET website google "www.google.com" # 覆盖一个旧域
(integer) 0

Redis hash (hash)