1。说明,redis 位图存储节省内存,用户id:156,1333; 如果用户登录,根据日期存储为1

setbit 20209001 156 1 ;//id为156的用户在1月1号登录了

setbit 20200901 1333 1; //id为1333的用户在1月1号登录了

setbit 20209002 156 1 ;//id为156的用户在1月2号登录了

BITOP AND destkey key [key ...] ,对一个或多个 key 求逻辑并,并将结果保存到 destkey 。
BITOP OR destkey key [key ...] ,对一个或多个 key 求逻辑或,并将结果保存到 destkey 。
BITOP XOR destkey key [key ...] ,对一个或多个 key 求逻辑异或,并将结果保存到 destkey 。
BITOP NOT destkey key ,对给定 key 求逻辑非,并将结果保存到 destkey
 
计算1号2号的用户活跃数量
bitop or result 20200901 20200902
获得用户活跃数量: bitcount result //2
 
 

相关文章:

  • 2018-11-11
  • 2021-05-20
  • 2021-09-14
  • 2021-09-24
  • 2021-04-12
  • 2021-04-15
  • 2022-01-11
  • 2021-05-10
猜你喜欢
  • 2022-12-23
  • 2021-10-30
  • 2021-06-29
  • 2022-12-23
  • 2022-12-23
  • 2021-11-21
  • 2022-12-23
相关资源
相似解决方案