Redis的基本数据类型有5种:
- String
- 列表(List)
- 哈希(Hash)
- 集合(Set)
- 有序集合(Sorted-set)
一、Redis的String操作
Paste_Image.png二、Redis的列表(List)操作
Paste_Image.png三、Redis的哈希(Hash)操作
Paste_Image.png四、Redis的集合(Set)操作
Paste_Image.png127.0.0.1:6379> smembers myset
1) "\xe7\x9a\x84d"
2) "a"
3) "c"
127.0.0.1:6379> sadd duridset 11 22 33 33
(integer) 3
127.0.0.1:6379> smembers duridset
1) "11"
2) "22"
3) "33"
127.0.0.1:6379> srem duridset 11
(integer) 1
127.0.0.1:6379> sdiffstore diffset duridset myset
(integer) 2
127.0.0.1:6379> smembers diffset
1) "22"
2) "33"
127.0.0.1:6379> sismember duridset 11
(integer) 0
127.0.0.1:6379> sismember duridset 22
(integer) 1
127.0.0.1:6379> smembers duridset
1) "22"
2) "33"
127.0.0.1:6379> sunion unionset duridset myset
1) "a"
2) "\xe7\x9a\x84d"
3) "33"
4) "22"
5) "c"
127.0.0.1:6379> smembers unionset
(empty list or set)
127.0.0.1:6379> sunionstore unionset duridset myset
(integer) 5
127.0.0.1:6379> smembers unionset
1) "a"
2) "\xe7\x9a\x84d"
3) "33"
4) "22"
5) "c"
网友评论