当前位置:网站首页>11_Redis_Hyperloglog_命令
11_Redis_Hyperloglog_命令
2022-07-02 12:00:00 【听*雨声】
Hyperloglog
什么是基数?
A{ 1,3,5,7,8,7 }
B{ 1,3,5,7,8 }
基数(不重复的元素) = 5,可以接受误差!
简介
Redis 2.8.9版本就更新了Hyperloglog数据结构!
Redis Hyperloglog基数统计的算法!
优点:占用的内存是固定,2^64不同的元素的技术,只需要废12KB内存!如果要从内存角度来比较的话Hyperloglog首选!
网页的UV(一个人访问一个网站多次,但是还是算作一个人! ) 0.81%错误率!统计UV任务,可以忽略不计的!
传统的方式,set(元素不允许重复)保存用户的id,然后就可以统计set 中的元素数量作为标准判断!
这个方式如果保存大量的用户id,就会比较麻烦!我们的目的是为了计数,而不是保存用户id;
127.0.0.1:6379> PFADD mykey a b c d e f g h i j k // 创建第一组元素
(integer) 1
127.0.0.1:6379> PFCOUNT mykey // 统计 mykey元素的基数数量
(integer) 11
127.0.0.1:6379> PFADD mykey2 i j k z d e // 创建第二组元素mykey2
(integer) 1
127.0.0.1:6379> PFCOUNT mykey2
(integer) 6
127.0.0.1:6379> PFMERGE mykey3 mykey mykey2 // 合并两组 mykey mykey2 => mykey3 并集
OK
127.0.0.1:6379> PFCOUNT mykey3 // 看并集的数量!
(integer) 12
如果允许容错,那么一定可以使用Hyperloglog
如果不允许容错,就使用set或者自己的数据类型即可!
边栏推荐
- Mfc a dialog calls B dialog function and passes parameters
- 21_Redis_浅析Redis缓存穿透和雪崩
- C#延时、在线程中开启定时器、获取系统时间
- geoserver离线地图服务搭建和图层发布
- Edit the formula with MathType, and set it to include only mathjax syntax when copying and pasting
- TiDB混合部署拓扑
- Huawei interview question: no palindrome string
- Ad20 cannot select the solution of component packaging in PCB editor
- 871. Minimum refueling times: simple priority queue (heap) greedy question
- [noi Simulation Competition] scraping (dynamic planning)
猜你喜欢

19_Redis_宕机后手动配置主机

Kityformula editor configure font size and spacing

Dragonfly low code security tool platform development path

学习使用php将时间戳转换为大写日期的方法代码示例

Have you learned the wrong usage of foreach

CodeCraft-22 and Codeforces Round #795 (Div. 2)D,E

Application and practice of Jenkins pipeline

vChain: Enabling Verifiable Boolean Range Queries over Blockchain Databases(sigmod‘2019)

Advanced C language (learn malloc & calloc & realloc & free in simple dynamic memory management)

Advanced C language (realize simple address book)
随机推荐
Niuke Practice 101
数据库内容输出有问题怎么解决
Tidb environment and system configuration check
17_Redis_Redis发布订阅
学习使用php将时间戳转换为大写日期的方法代码示例
19_Redis_宕机后手动配置主机
【NOI模拟赛】刮痧(动态规划)
Learn the method code of using PHP to realize the conversion of Gregorian calendar and lunar calendar
學習使用php實現公曆農曆轉換的方法代碼
TiDB数据迁移场景综述
871. Minimum refueling times: simple priority queue (heap) greedy question
kibana 基础操作
实用调试技巧
C# richTextBox控制显示最大行数
2021-2022学年编译原理考试重点[华侨大学]
vChain: Enabling Verifiable Boolean Range Queries over Blockchain Databases(sigmod‘2019)
Mavn builds nexus private server
btrace-(字节码)动态跟踪工具
Error: NPM warn config global ` --global`, `--local` are deprecated Use `--location=global` instead.
About text selection in web pages and counting the length of selected text