module Oxblood::Commands::HyperLogLog

Public Instance Methods

pfadd(key, *elements) click to toggle source

Adds the specified elements to the specified HyperLogLog. @see redis.io/commands/pfadd

@param [String] key @param [String, Array<String>] elements

@return [Integer] 1 if at least 1 HyperLogLog internal register was

altered and 0 otherwise.
# File lib/oxblood/commands/hyper_log_log.rb, line 12
def pfadd(key, *elements)
  run(*elements.unshift(:PFADD, key))
end
pfcount(*keys) click to toggle source

Return the approximated cardinality of the set(s) observed by the HyperLogLog at key(s). @see redis.io/commands/pfcount

@param [String, Array<String>] keys

@return [Integer] the approximated number of unique elements observed

via {#pfadd}.
# File lib/oxblood/commands/hyper_log_log.rb, line 24
def pfcount(*keys)
  run(*keys.unshift(:PFCOUNT))
end
pfmerge(destkey, *sourcekeys) click to toggle source

Merge N different HyperLogLogs into a single one. @see redis.io/commands/pfmerge

@param [String] destkey @param [String, Array<String>] sourcekeys

@return [String] 'OK'

# File lib/oxblood/commands/hyper_log_log.rb, line 35
def pfmerge(destkey, *sourcekeys)
  run(*sourcekeys.unshift(:PFMERGE, destkey))
end