Redis文法紹介のHashs

1214 ワード

KVモードは変わりません.単一Vはキー値ペアです.
一、増加
127.0.0.1:6379> hset user name bin //   user  name
(integer) 1
127.0.0.1:6379> hmset user age 23 sex male //        
OK
127.0.0.1:6379> hmget user name age sex
1) "bin"
2) "23"
3) "male"
127.0.0.1:6379> hsetnx user age 40 // age      ,     ,       0
(integer) 0

二、削除
127.0.0.1:6379> hdel user name //   name 
(integer) 1

三、改める
127.0.0.1:6379> HINCRBY user age 3 //   age  
127.0.0.1:6379> hset user score 91.3
(integer) 1
127.0.0.1:6379> HINCRBYFLOAT user score 0.5 //        
"91.8"

三、調査
127.0.0.1:6379> hget user name //     name  
127.0.0.1:6379> hmget user name age sex //       
1) "bin"
2) "23"
3) "male"
127.0.0.1:6379> hgetall user //    user       
1) "name"
2) "bin"
3) "age"
4) "23"
5) "sex"
6) "male"
127.0.0.1:6379> hkeys user //   user     
1) "age"
2) "sex"
127.0.0.1:6379> hvals user //   user     
1) "23"
2) "male"
127.0.0.1:6379> hexists user age //   age     
(integer) 1