English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
Il comando Redis Hsetnx viene utilizzato per assegnare valori a campi che non esistono già in una tabella hash.
Se la hash table non esiste, viene creata una nuova hash table e viene eseguita l'operazione Hset .
Se il campo esiste già nella hash table, l'operazione è invalida.
Se il key non esiste, viene creato un nuovo hash table e viene eseguito il comando Hsetnx .
Sintassi del comando Hsetnx Redis
redis 127.0.0.1:6379> HSETNX KEY_NAME FIELD VALUE
>= 2.0.0
Impostazione riuscita, restituito 1 . Se il campo specificato esiste e non viene eseguita alcuna operazione, viene restituito 0 .
redis 127.0.0.1:6379> HSETNX myhash field1 "foo" (intero) 1 redis 127.0.0.1:6379> HSETNX myhash field1 "bar" (intero) 0 redis 127.0.0.1:6379> HGET myhash field1 "foo" redis 127.0.0.1:6379> HSETNX nosql key-value-store redis (intero) 1 redis 127.0.0.1:6379> HSETNX nosql key-value-store redis # Operazione non valida, key-value-store esiste già (intero) 0