当前位置:网站首页>Redis 做网页UV统计
Redis 做网页UV统计
2022-08-01 19:49:00 【Mar丶流年】
前言
首先要明白什么是UV,即独立访客记录(同一个用户多次访问同一个页面,也只算这个页面被这个用户访问过一次),这个要求我们使用的redis数据类型有去重功能。建议使用HyperLogLog实现
使用set实现
假设用户1访问了三次A页面
# 1 代表用户id
sadd A:20220801 1
sadd A:20220801 1
sadd A:20220801 1
统计A页面的UV
# UV = 1
scard A:20220801
使用hash实现
假设用户1访问了三次A页面
# 最后的1填其它的也行,只是用来占位
hset A:20220802 1 1
hset A:20220802 1 1
hset A:20220802 1 1
统计A页面的UV
# UV = 1
hlen A:20220802
使用HyperLogLog实现
HyperLogLog 的优点是,在输入元素的数量或者体积非常非常大时,计算基数所需的空间总是固定 的、并且是很小的。
假设用户1访问了三次A页面
# 一次性添加三个1进去
pfadd A:20220803 1 1 1
统计A页面的UV
# UV = 1
pfcount A:20220803
边栏推荐
- 部署zabbix
- 17. Load balancing
- Source code analysis of GZIPOutputStream class
- 开源视界 | StreamNative 盛宇帆:和浪漫的人一起做最浪漫的事
- Pytorch模型训练实用教程学习笔记:二、模型的构建
- 多线程之生产者与消费者
- In the background of the GBase 8c database, what command is used to perform the master-slave switchover operation for the gtm and dn nodes?
- 我的驾照考试笔记(2)
- latex论文神器--服务器部署overleaf
- openresty 动态黑白名单
猜你喜欢

【kali-信息收集】(1.3)探测网络范围:DMitry(域名查询工具)、Scapy(跟踪路由工具)

因斯布鲁克大学团队量子计算硬件突破了二进制

Database Plus 的云上之旅:SphereEx 正式开源 ShardingSphere on Cloud 解决方案

升哲科技携全域数字化方案亮相2022全球数字经济大会

58:第五章:开发admin管理服务:11:开发【管理员人脸登录,接口】;(未实测)(使用了阿里AI人脸识别)(演示了,使用RestTemplate实现接口调用接口;)

GEE(8):使用MODIS填补由去云后的Landsat影像计算得到的NDVI数据

智能硬件开发怎么做?机智云全套自助式开发工具助力高效开发

XSS range intermediate bypass
![58: Chapter 5: Develop admin management services: 11: Develop [admin face login, interface]; (not measured) (using Ali AI face recognition) (demonstrated, using RestTemplate to implement interface cal](/img/ab/1c0adeb344329e28010b6ffda5389d.png)
58: Chapter 5: Develop admin management services: 11: Develop [admin face login, interface]; (not measured) (using Ali AI face recognition) (demonstrated, using RestTemplate to implement interface cal

How PROE/Croe edits a completed sketch and brings it back to sketching state
随机推荐
MySQL你到底都加了什么锁?
When installing the GBase 8c database, the error message "Resource: gbase8c already in use" is displayed. How to deal with this?
如何写一个vim插件?
Win11校园网无法连接怎么办?Win11连接不到校园网的解决方法
【Redis】缓存雪崩、缓存穿透、缓存预热、缓存更新、缓存击穿、缓存降级
Creo5.0 rough hexagon is how to draw
Ha ha!A print function, quite good at playing!
网络不通?服务丢包?这篇 TCP 连接状态详解及故障排查,收好了~
Every calculation, & say what mean
Try compiling QT test on Allwinner V853 development board
启明云端分享|盘点ESP8684开发板有哪些功能
力扣刷题之合并两个有序数组
18. Distributed configuration center nacos
Arthas 常用命令
大神经验:软件测试的自我发展规划
因斯布鲁克大学团队量子计算硬件突破了二进制
kingbaseV8R3和postgreSQL哪个版本最接近?
app直播源码,点击搜索栏自动弹出下拉框
What should I do if the Win11 campus network cannot be connected?Win11 can't connect to campus network solution
ssh & scp