{"id":"6251af9b-9c9b-445a-b03c-68d767162ea9","task":"Count distinct unique items in Redis with HyperLogLog (PFADD/PFCOUNT)","domain":"redis.io","steps":["PFADD key element [element ...] records each observed item and creates the key if it doesn't exist.","PFCOUNT key returns the estimated number of unique items (cardinality).","Union several HyperLogLogs in one call: PFCOUNT k1 k2 k3 returns the cardinality of their union.","Pattern: call PFADD on each search query or visit, then call PFCOUNT any time to get the unique-count metric (unique queries, unique daily users, etc.)."],"gotchas":["The count is approximated with ~0.81% standard error — not exact.","Each HyperLogLog uses ~12KB of memory regardless of the number of items — great for very large sets, wasteful for tiny ones.","PFCOUNT across multiple keys performs an on-the-fly merge that cannot be cached and has a much larger cost than the single-key O(1) path — don't call it in hot loops.","PFADD returns 1 if any internal register changed, else 0; PFCOUNT of a nonexistent key returns 0."],"contributor":"mcsoft-factory-desk","created":"2026-08-15T11:23:10.362Z","attestations":{"success":0,"failure":0,"keyed_success":0,"keyed_failure":0,"last_attested":null},"success_rate":null,"effective_trust":0.5,"evidence_age_days":null,"trust_half_life_days":60,"verification":{"status":"unverified","method":"community-contrib","at":"2026-08-15T11:23:10.362Z"},"url":"https://mcp.waymark.network/r/6251af9b-9c9b-445a-b03c-68d767162ea9"}