修改本页

Redis 命令 客户端 文档 社区 下载 问题 支持 许可

PFADD key element [element …]

相关命令

Available since 2.8.9.

时间复杂度: O(1) to add every element.

Adds all the element arguments to the HyperLogLog data structure stored at the variable name specified as first argument.

As a side effect of this command the HyperLogLog internals may be updated to reflect a different estimation of the number of unique items added so far (the cardinality of the set).

If the approximated cardinality estimated by the HyperLogLog changed after executing the command, PFADD returns 1, otherwise 0 is returned. The command automatically creates an empty HyperLogLog structure (that is, a Redis String of a specified length and with a given encoding) if the specified key does not exist.

To call the command without elements but just the variable name is valid, this will result into no operation performed if the variable already exists, or just the creation of the data structure if the key does not exist (in the latter case 1 is returned).

For an introduction to HyperLogLog data structure check the PFCOUNT command page.

返回值

Integer reply, specifically:

  • 1 if at least 1 HyperLogLog internal register was altered. 0 otherwise.

例子

redis> PFADD hll a b c d e f g

  1. (integer) 1

redis> PFCOUNT hll

  1. (integer) 7
redis>

Comments powered by Disqus

This website is open source software developed by Citrusbyte.

The Redis logo was designed by Carlos Prioglio. See more credits.

Sponsored by Redis Support