Important Commands in Redis

HSET– It will set the field in the hash stored at key to value if field does not exist. If key does not exist, it will create one for you. If field already exist, it has no impact on the hash.

hset key field value //accepts three arguments and all are required
hset amazonItems Table "StandingDesk" //Output - (integer) 1

HGET– It will return the value connected with field in the hash stored at the key.

hget key field //All are required arguments
hget amazonItems Table //Output - "StandingDesk"

HKEYS – It will return all the keys for the provided hash

HKEYS amazonItems //Output - 1) "Table"

HEXIST – It will return integer. 1 if hash contains the field or else 0

hexists amazonItems Table //Output-  (integer) 1
hexists amazonItems Chair //Output - (integer) 0

HDEL – It deletes the provided key from the hash stored at key. return value will be integer. 1 if it is deleted, 0 if it is not deleted or do not exist.

hdel amazonItems Table //Output- (integer) 1
hdel amazonItems Chair //Output- (integer) 0

I hope this post was helpful to you. If you like my post, follow me @twitter/andramazo.

Begin typing your search term above and press enter to search. Press ESC to cancel.

Back To Top