zoukankan      html  css  js  c++  java
  • redis之HyperLogLog

      HyperLogLog 提供不精确的去重计数方案,虽然不精确但是也不是非常不精确,标准误差是 0.81%。

    使用方法

      HyperLogLog 提供了两个指令 pfadd 和 pfcount,根据字面意义很好理解,一个是增加计数,一个是获取计数。

    127.0.0.1:6379> pfadd codehole user1
    (integer) 1
    127.0.0.1:6379> pfcount codehole
    (integer) 1
    127.0.0.1:6379> pfadd codehole user2
    (integer) 1
    127.0.0.1:6379> pfcount codehole
    (integer) 2
    127.0.0.1:6379> pfadd codehole user3
    (integer) 1
    127.0.0.1:6379> pfcount codehole
    (integer) 3
    127.0.0.1:6379> pfadd codehole user4
    (integer) 1
    127.0.0.1:6379> pfcount codehole
    (integer) 4
    127.0.0.1:6379> pfadd codehole user5
    (integer) 1
    127.0.0.1:6379> pfcount codehole
    (integer) 5
    127.0.0.1:6379> pfadd codehole user6
    (integer) 1
    127.0.0.1:6379> pfcount codehole
    (integer) 6
    127.0.0.1:6379> pfadd codehole user7 user8 user9 user10
    (integer) 1
    127.0.0.1:6379> pfcount codehole
    (integer) 10

    HyperLogLog 除了上面的 pfadd 和 pfcount 之外,还提供了第三个指令 pfmerge,用于将多个 pf 计数值累加在一起形成一个新的 pf 值。

  • 相关阅读:
    非阻塞式线程安全列表-ConcurrentLinkedDeque
    计数器
    Linux 查看服务器内存使用情况
    Oracle to_date, to_timestamp
    Hibernate session.flush() 使用
    阿里规约认证(题库附答案)
    多态性
    Java数据类型
    String类特点分析
    数组的定义
  • 原文地址:https://www.cnblogs.com/wuwuyong/p/11741507.html
Copyright © 2011-2022 走看看