简介
- Redis HyperLogLog 即基数统计,有误差
- 基数:不重复的元素
- 使用场景:网页访问统计
命令
| 命令 | 解释 | | —- | —- | | PFADD key element [element …] | 将指定元素添加到HyperLogLog | | PFCOUNT key [key …] | 返回由HyperLogLog在键处观察到的集合的近似基数。 | | PFMERGE destkey sourcekey [sourcekey …] | 将N个不同的HyperLogLog合并到一个日志中。 |
例子
hello-chen.cn:6379> PFADD letter1 a b c d e
(integer) 1
hello-chen.cn:6379> PFADD letter2 c d e f g
(integer) 1
hello-chen.cn:6379> PFCOUNT letter1
(integer) 5
hello-chen.cn:6379> PFMERGE letter3 letter1 letter2
OK
hello-chen.cn:6379> PFCOUNT letter3
(integer) 7
其他
http://www.redis.cn/commands.html#hyperloglog
PFADD key element [element ...]
summary: Adds the specified elements to the specified HyperLogLog.
since: 2.8.9
PFCOUNT key [key ...]
summary: Return the approximated cardinality of the set(s) observed by the HyperLogLog at key(s).
since: 2.8.9
PFMERGE destkey sourcekey [sourcekey ...]
summary: Merge N different HyperLogLogs into a single one.
since: 2.8.9