redis api hash

歷精圖治發表於2018-11-08

key field
user:1:info name Ronaldo
age 40
Date 201
viewCounter

hget key field 
#獲取hash key對應的field的value
hset key field value 
#設定hash key對應field的value
hdel key field 
#刪除hash key對應的field的value 
hset user:1:info age 23 
1 
hget user:1:info age 
"23"
hset user:info name ronaldo 
(integer)1
hgetall user:1:info 
1) "age"
2)"23"
3)"name"
4)"ronaldo"
hdel user:1:info age 
(integer)
hgetall user:1:info 
1)"name"
2)"ronaldo" 

**hexists,hlen **

hexits key field 
hlen key 
hgetall user:1:info 
1)"name"
2)"ronaldo"
3)"age"
4)"23" 
hexists user:1:info name 
1
hlen user:1:info 
2 

hmget hmset

hmset user:2:info age 30 name kaka 

相關文章