redis-散列

1、hget hset hmget hmset hexists hgetall hdel

127.0.0.1:6379> hgetall userinfo
 1) "name"
 2) "\xe5\xbc\xa0\xe4\xb8\x89"
 3) "pwd"
 4) "000000"
 5) "address"
 6) " beijing caoyangqu"
 7) "tel"
 8) "1367114433"
 9) "code"
10) "102207"
127.0.0.1:6379> hexists userinfo pwd
(integer) 1
127.0.0.1:6379> hsetnx userinfo pwd 123
(integer) 0
127.0.0.1:6379> hincrby userinfo code 12

(integer) 102219

127.0.0.1:6379> hdel userinfo code
(integer) 1
127.0.0.1:6379> hget userinfo code
(nil)
2、hsetnx 当存在此键,则返回0 

127.0.0.1:6379> hsetnx userinfo code 3333
(integer) 1
127.0.0.1:6379> hsetnx userinfo code 342
(integer) 0

3、hkeys 、hvals 只获取字段名或字段值 ,hlen 字段的数量

127.0.0.1:6379> hkeys userinfo
1) "name"
2) "pwd"
3) "address"
4) "tel"
5) "code"
127.0.0.1:6379> hvals userinfo
1) "\xe5\xbc\xa0\xe4\xb8\x89"
2) "000000"
3) " beijing caoyangqu"
4) "1367114433"
5) "3333

127.0.0.1:6379> hlen userinfo
(integer) 5

你可能感兴趣的:(redis-散列)