w3resource

Redis HyperLogLog: PFADD

Redis PFADD Command

Redis PFADD command is used to add all the element arguments to the HyperLogLog data structure stored at the key name specified as the first argument.

Here are some common uses and scenarios for the "PFADD" command:

  • Approximate Cardinality: Adds elements to a HyperLogLog data structure to approximate the cardinality (unique count) of a set.
  • Memory Efficiency: Provides a memory-efficient way to estimate the number of unique elements in large datasets without storing all elements.
  • Distinct Count Estimation: Useful for counting distinct items in streams of data, such as unique visitors to a website or unique events in a log.
  • Big Data Analysis: Helps in big data analysis scenarios where precise counts are not required, but approximate counts are sufficient.

Syntax:

PFADD KEY_NAME ELEMENTS_TO_BE_ADDED

Available since

2.8.9.

Return Value

Integer reply, 1 or 0.

Return Value Type

Integer

Example: Redis PFADD

redis 127.0.0.1:6379> PFADD mykey a b c d e f g h i j
(integer) 1
redis 127.0.0.1:6379> PFCOUNT mykey
(integer) 10

Previous: ZSCAN
Next: PFCOUNT



Follow us on Facebook and Twitter for latest update.