当前位置:网站首页>Redis does check-in statistics
Redis does check-in statistics
2022-08-01 20:01:00 【Mar, fleeting】
Article table of contents
Foreword
If there are only two states (yes or no) like check-in, binary state statistics can be used.bitmap conforms to binary state statistics (0,1), and takes up little space
Count check-ins in a month
Here takes user id: 1, August as an example, assuming 1, 3, 5, 7, 9 check-in
setbit sign:1:202208 1 1setbit sign:1:202208 3 1setbit sign:1:202208 5 1setbit sign:1:202208 7 1setbit sign:1:202208 9 1
Count the number of check-in days in the current month
# get signed in for 5 daysbitcount sign: 1:202208
Check if a day in the current month is checked in
# 3rd signed ingetbit sign:202208 3# No check-in on the 4thgetbit sign:202208 4
Counting consecutive check-ins
It is not suitable to use user id + month as the key for continuous check-in statistics.
Here, the specific check-in days are used as the key, and the bit position is used as the user id.
Suppose 20220801, users 1, 3, 5, 7, and 9 check in.
setbit sing:20220801 1 1setbit sing:20220801 3 1setbit sing:20220801 5 1setbit sing:20220801 7 1setbit sing:20220801 9 1
20220802, users 3, 7, 9 check in
setbit sing:20220802 3 1setbit sing:20220802 7 1setbit sing:20220802 9 1
20220803, user 5, 9 signed in
setbit sing:20220803 5 1setbit sing:20220803 9 1
Count the number of users who logged in on August 1, 2, and 3
# Put the bitwise AND results of the three dates into resultbitop and result sing:20220801 sing:20220802 sing:20220803# Statistics of consecutive check-ins# Only one user gets consecutive check-insbitcount result
边栏推荐
- 【节能学院】安科瑞餐饮油烟监测云平台助力大气污染攻坚战
- nacos installation and configuration
- Does LabVIEW really close the COM port using VISA Close?
- Debug一个ECC的ODP数据源
- ssh & scp
- 57:第五章:开发admin管理服务:10:开发【从MongoDB的GridFS中,获取文件,接口】;(从GridFS中,获取文件的SOP)(不使用MongoDB的服务,可以排除其自动加载类)
- 油猴hook小脚本
- [Personal Work] Remember - Serial Logging Tool
- 10 个 PHP 代码安全漏洞扫描程序
- deploy zabbix
猜你喜欢
随机推荐
An implementation of an ordered doubly linked list.
1个小时!从零制作一个! AI图片识别WEB应用!
Software you should know as a programmer
The graphic details Eureka's caching mechanism/level 3 cache
数据库系统原理与应用教程(071)—— MySQL 练习题:操作题 110-120(十五):综合练习
Redis 做网页UV统计
Wildcard SSL/TLS certificate
常用命令备查
【webrtc】sigslot : 继承has_slot 及相关流程和逻辑
LTE时域、频域资源
安装win32gui失败,解决问题
第56章 业务逻辑之物流/配送实体定义
nacos installation and configuration
油猴hook小脚本
58:第五章:开发admin管理服务:11:开发【管理员人脸登录,接口】;(未实测)(使用了阿里AI人脸识别)(演示了,使用RestTemplate实现接口调用接口;)
手撸代码,Redis发布订阅机制实现
分享一个适用于MCU项目的代码框架
Creo5.0 rough hexagon is how to draw
作为程序员你应该会的软件
第59章 ApplicationPart内置依赖注入中间件