Command builders for Redis Count-Min Sketch (CMS.*) operations.
A Count-Min Sketch is a probabilistic data structure for estimating the frequency of items in a data stream. It uses a fixed-size matrix of counters addressed by multiple hash functions. Frequency estimates may overcount but will never undercount, making it useful for approximate frequency queries where a small positive bias is acceptable.
All functions in this module are pure and return a command list (a list of
strings) suitable for passing to Redis.command/2 or Redis.pipeline/2.
Examples
# Initialize by exact dimensions (width x depth)
Redis.command(conn, CMS.initbydim("clicks", 2000, 5))
# Increment counts and query frequencies
Redis.pipeline(conn, [
CMS.incrby("clicks", [{"page_a", 3}, {"page_b", 1}]),
CMS.query("clicks", ["page_a", "page_b"])
])
Summary
Functions
Increments the count of one or more items. Each element in the list is a
{item, increment} tuple.
Initializes a Count-Min Sketch with the given width and depth.
Initializes a Count-Min Sketch with a desired error rate and probability
of exceeding that error. This is a convenience alternative to initbydim/3
that lets Redis choose the matrix dimensions.
Functions
Increments the count of one or more items. Each element in the list is a
{item, increment} tuple.
@spec initbydim(String.t(), non_neg_integer(), non_neg_integer()) :: [String.t()]
Initializes a Count-Min Sketch with the given width and depth.
The width controls accuracy (more columns = less overcounting) and
depth controls confidence (more rows = lower probability of large error).
Initializes a Count-Min Sketch with a desired error rate and probability
of exceeding that error. This is a convenience alternative to initbydim/3
that lets Redis choose the matrix dimensions.