登录

php - redis的HyperLogLog有什么用?

如果是单纯计算基数的话,使用HyperLogLog之前还得先一个一个PFADD,我在业务代码(php,java)中调用PFADD的时候换成用increment给一个string类型的专门用于统计基数的键来计算不就好了嘛?

所以说是我的用法不正确吗?HyperLogLog应该是在哪种场景下使用?如何正确科学的使用?

# PHP
高洛峰 高洛峰 2565 天前 385 次浏览

全部回复(1) 我要回复

  • 伊谢尔伦

    伊谢尔伦2017-04-11 10:30:16

    维基百科上有写的啊:

    approximating the number of distinct elements in a multiset. Calculating the exact cardinality of a multiset requires an amount of memory proportional to the cardinality, which is impractical for very large data sets. Probabilistic cardinality estimators, such as the HyperLogLog algorithm, use significantly less memory than this, at the cost of obtaining only an approximation of the cardinality.

    简单来说就是用正确性换空间。如果你的数据量不大当然用不上。比如你的移动应用有多少个安装(使用 UUID 标识的)。

    回复
    0
  • 取消 回复 发送