Redis Set结构使用场景
1、抽奖 1)、用户参与抽奖:SADD order 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 2)、查看所有参与抽奖的人:SMEMBERS order 3)、重复抽奖每次抽取两人:SMEMBERS order 2 4)、不重复抽奖,三等奖3人,二等奖2人,一等奖1人 SPOP order 3 SPOP order 2 SPOP order 1 2、点赞、收藏、标签 1)、点赞的人:SADD like:1 1001 1002 1003 1004 1005 2)、取消点赞:SREM like:1 1002 3)、检查用户是否点赞过: SISMEMBER like:1 1002 SISMEMBER like:1 1005 4)、获取点赞人员列表:SMEMBERS like:1 5)、获取点赞总人数:SCARD like:1 3、关注模型 127.0.0.1:6379> SADD wangwu zhangsan lisi zhaoliu haoba (integer) 4 127.0.0.1:6379> SADD zhangsan lisi wangwu sijiu (integer) 3 127.0.0.1:6379> SADD lisi zhaoliu zhangsan qinshi (integer) 3 127.0.0.1:6379> SINTER wangwu zhangsan 1) "lisi" 127.0.0.1:6379> SISMEMBER zhangsan lisi (integer) 1 127.0.0.1:6379> SISMEMBER lisi zhangsan (integer) 1 127.0.0.1:6379> SISMEMBER zhaoliu zhangsan (integer) 0 127.0.0.1:6379> SISMEMBER haoba zhangsan (integer) 0 127.0.0.1:6379> SDIFF zhangsan wangwu 1) "sijiu" 2) "wangwu" 127.0.0.1:6379> SDIFF lisi wangwu 1) "qinshi"
相关推荐
王道革 2020-11-25
wangdonghello 2020-11-03
Langeldep 2020-11-16
chenhualong0 2020-11-16
聚合室 2020-11-16
koushr 2020-11-12
MRFENGG 2020-11-11
guoyanga 2020-11-10
fackyou00 2020-11-10
Orangesss 2020-11-03
dongCSDN 2020-10-31
rainandtear 2020-10-30
Quietboy 2020-10-30
liuyulong 2020-10-29
fansili 2020-10-29
温攀峰 2020-10-23
jackbon 2020-10-19
kaixinfelix 2020-10-04