Redis › HyperLogLog in Redis
How do you add items to a HyperLogLog and get an estimated count of unique items using Redis?
BeginnerAnswer
You use PFADD to add one or more items to a HyperLogLog structure, and PFCOUNT to retrieve the current estimated number of unique items that have been added, with Redis automatically creating the HyperLogLog structure the first time you add an item to a new key.
PFADD page_views:homepage 'visitor1' 'visitor2' 'visitor3'
PFCOUNT page_views:homepageReal-world example A marketing analytics dashboard tracks the estimated number of unique visitors to each page on a website, adding visitor identifiers with PFADD and displaying the running estimate using PFCOUNT.