Latest web development tutorials

comando Redis HSEt

Redis de hash (hash)

Redis comando HSEt é usado para hash atribuição de campo mesa.

Se a tabela de hash não existe, uma nova tabela hash é criado e operação HSEt.

Se o campo já existe na tabela de hash, o valor antigo será substituído.

gramática

Redis HSEt sintaxe de comando básica é a seguinte:

redis 127.0.0.1:6379> HSET KEY_NAME FIELD VALUE 

versões disponíveis

> = 2.0.0

Valor de retorno

Se o campo estiver na tabela de hash um novo campo, e defina o valor de sucesso, 1 é retornado. Se a tabela hash já existe no campo de domínio e o valor antigo será substituído pelo novo valor, retornar 0.

Exemplos

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 de hash (hash)