Redis的HyperLogLog
Redis 在 2.8.9 版本新增了HyperLogLog 結構。
Redis HyperLogLog 是用來做基數統計的演算法,HyperLogLog的優點是,在輸入元素的數量或者體積非常非常大時,計算基數所需的空間總是固定的、並且是很小的。
在 Redis 裡面,每個 HyperLogLog 鍵只需要花費 12 KB 記憶體,就可以計算接近 2^64 個不同元素的基數。這和計算基數時,元素越多耗費記憶體就越多的集合形成鮮明對比。
但是,因為 HyperLogLog 只會根據輸入元素來計算基數,而不會儲存輸入元素本身,所以 HyperLogLog 不能像集合那樣,返回輸入的各個元素。
什麼是基數?
比如資料集 {1, 3, 5, 7, 5, 7, 8},那麼這個資料集的基數集為 {1, 3, 5 ,7, 8}, 基數(不重複元素)為5。基數估計就是在誤差可接受的範圍內,快速計算基數。
本次演示HyperLogLog的基本操作
127.0.0.1:6379> pfadd test_hyper "lalala"
(integer) 1
127.0.0.1:6379> pfadd test_hyper "bbblll"
(integer) 1
127.0.0.1:6379> pfadd test_hype r"cacaca"
(integer) 1
127.0.0.1:6379> pfcount test_hyper
(integer) 3
RedisHyperLogLog 命令
PFADD key element [element ...] 新增指定元素到HyperLogLog 中。
PFCOUNT key [key ...] 返回給定HyperLogLog 的基數估算值。
PFMERGE destkey sourcekey [sourcekey ...] 將多個HyperLogLog 合併為一個 HyperLogLog
相關文章
- Redis的Bitmap、HyperLogLog和GeoRedis
- Redis 中 HyperLogLog 的使用場景Redis
- redis知識之HyperLogLogRedis
- Redis 集合統計(HyperLogLog)Redis
- 初識Redis的資料型別HyperLogLogRedis資料型別
- Redis HyperLogLog介紹及應用Redis
- Redis Hyperloglog的原理及數學理論的通俗理解Redis
- 學透 Redis HyperLogLog,看這篇就夠了Redis
- Redis 三種特殊資料型別之 HyperloglogRedis資料型別
- Redis中 HyperLogLog資料型別使用總結Redis資料型別
- HyperLogLog
- HyperLogLog 演算法的原理講解以及 Redis 是如何應用它的演算法Redis
- redis個人原始碼分析1----hyperloglog(golang實現)Redis原始碼Golang
- redis——集合,有序,慢查詢, pipline與事務, bitmap ,HyperLogLog geoRedis
- 【Redis的那些事 · 續集】Redis的點陣圖、HyperLogLog資料結構演示以及布隆過濾器Redis資料結構過濾器
- 見縫插針 —— 深入 Redis HyperLogLog 內部資料結構分析Redis資料結構
- openGauss 支援HyperLogLog
- Redis基礎知識(學習筆記13--BitMap、HyperLogLog 與 Geospatial的操作命令)Redis筆記
- 使用者日活月活怎麼統計 - Redis HyperLogLog 詳解Redis
- Redis 必知必會之慢查詢、Pipeline、釋出訂閱、Bitmap、HyperLogLog、GEORedis
- HyperLogLog:海量資料下的基數計算
- Redis HyperLogLog 是什麼?這些場景使用它,讓我槍出如龍,一笑破蒼穹Redis
- 故事:坐在我隔壁的小王問我什麼是HyperLogLog
- 【Redis】Redis的操作命令(一)——Redis Key命令Redis
- Redis(1)_Redis的基本認識Redis
- Redis(四)--- Redis的命令參考Redis
- 慢查詢、pipline、釋出訂閱、 bitmap點陣圖、 hyperloglog、geo、持久化持久化
- 看看redis中那些好玩的module (sql on redis, bf/cf on redis)RedisSQL
- 【Redis】redis-cluster到redis-cluster的快速複製Redis
- Redis5 的新特性 Redis StreamRedis
- Java Redis系列2 (redis的安裝與使用+redis持久化的實現))JavaRedis持久化
- Redis的使用Redis
- Redis的概述Redis
- 【Azure Redis 快取 Azure Cache For Redis】使用Redis自帶redis-benchmark.exe命令測試Azure Redis的效能Redis快取
- redis學習筆記(三)–Redis的功能Redis筆記
- 【Redis】 redis-cluster刪除指定的keyRedis
- 【Redis】基於consul的Redis高可用方案Redis
- 《Redis實戰》筆記-Redis的有序集合Redis筆記
- Redis(五)--- Redis的持久化RDB與AOFRedis持久化