redis集合

redis> sadd myset a

(integer) 1
redis> sadd myset b
(integer) 1
redis> sadd myset c d ef
(integer) 3
redis> sadd myset c d e f
(integer) 2
redis> smembers myset
1) "d"
2) "c"
3) "f"
4) "b"
5) "ef"
6) "e"
7) "a"
redis>
redis> srem myset 5
(integer) 0
redis> smembers myset
1) "d"
2) "c"
3) "f"
4) "b"
5) "ef"
6) "e"
7) "a"
redis> srem myset ef
(integer) 1
redis> smembers myset
1) "d"
2) "c"
3) "f"
4) "b"
5) "e"
6) "a"
redis> scard myset
(integer) 6
redis> sismember myset a
(integer) 1
redis> sismember myset aa
(integer) 0
redis>
redis>
redis>
redis> sadd set1 a b c
(integer) 3
redis>
redis> sadd set2 a b d
(integer) 3
redis>
redis>
redis> smembers set1
1) "c"
2) "b"
3) "a"
redis> smembers set2
1) "d"
2) "b"
3) "a"
redis>
redis> sdiff set1 set2
1) "c"
redis> sinter set1 set2
1) "b"
2) "a"
redis> sunion set1 set2
1) "b"
2) "c"
3) "a"
4) "d"

    A+
发布日期:2018年11月30日  所属分类:未分类

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: