Redis Hash

HSET

http://redisdoc.com/hash/hset.html

HSET hash field value

127.0.0.1:6379> HSET website google "www.google.com"
(integer) 1
127.0.0.1:6379> HGET website google
"www.google.com"

HGET hash field

http://redisdoc.com/hash/hget.html HGET hash field

127.0.0.1:6379> HGET website google
"www.google.com"

HMSET

http://redisdoc.com/hash/hmset.html HMSET key field value [field value …]

HGETALL

http://redisdoc.com/hash/hgetall.html HGETALL key

127.0.0.1:6379> HGETALL website
1) "google"
2) "www.google.com"

HVALS

http://redisdoc.com/hash/hvals.html HVALS key

127.0.0.1:6379> HVALS website
1) "www.google.com"

HKEYS

http://redisdoc.com/hash/hkeys.html HKEYS key

127.0.0.1:6379> HKEYS website
1) "google"

HEXISTS

http://redisdoc.com/hash/hexists.html HEXISTS hash field

127.0.0.1:6379> HEXISTS website apple
(integer) 0
127.0.0.1:6379> HEXISTS website google
(integer) 1

HLEN

http://redisdoc.com/hash/hlen.html

HLEN key

127.0.0.1:6379> HLEN website
(integer) 1

HSETNX

http://redisdoc.com/hash/hsetnx.html HSETNX hash field value

HDEL

http://redisdoc.com/hash/hdel.html

HDEL key field [field …]

HINCRBY

http://redisdoc.com/hash/hincrby.html

HINCRBY key field increment

Cheat Sheet

HSET myhash field1 "Hello".  (Sets field in the hash stored at key to value. If field already exists in the hash, it is overwritten.)

HGET myhash field1 (Returns the value associated with field in the hash stored at key.)

HMSET myhash field1 "Hello" field2 "World" ( Set Multiple values.)

HGETALL myhash  (Returns all fields and values of the hash stored at key.)

HMGET myhash field1 field2 (Returns the values associated with the specified fields in the hash stored at key.)

HEXISTS myhash field1 (Returns if field is an existing field in the hash stored at key.)

HKEYS myhash (Returns all field names in the hash stored at key.)

HLEN myhash (Returns the number of fields contained in the hash stored at key.)

HSETNX myhash field "Hello" (Sets field in the hash stored at key to value, only if field does not yet exist.)

HDEL myhash field1 (Removes the specified fields from the hash stored at key.)

HINCRBY myhash field 1 (Increments the number stored at field in the hash stored at key by increment.)

HINCRBYFLOAT mykey field 0.1 (Increment the specified field of a hash stored at key, and representing a floating point number, by the specified increment.)

HSTRLEN myhash f1 (Returns the string length of the value associated with field in the hash stored at key.)

HVALS myhash (Returns all values in the hash stored at key.)
© Kimi Tsai all right reserved.            Updated : 2023-07-12 09:04:53

results matching ""

    No results matching ""

    results matching ""

      No results matching ""