Sha256: 87f78e330288a5c5e7aa3af482a369b321d1a71df3ddd026478c98c59f611cbe

Contents?: true

Size: 1.17 KB

Versions: 2

Compression:

Stored size: 1.17 KB

Contents

module Oxblood
  module Commands
    module HyperLogLog
      # Adds the specified elements to the specified HyperLogLog.
      # @see https://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.
      def pfadd(key, *elements)
        run(*elements.unshift(:PFADD, key))
      end

      # Return the approximated cardinality of the set(s) observed by
      # the HyperLogLog at key(s).
      # @see https://redis.io/commands/pfcount
      #
      # @param [String, Array<String>] keys
      #
      # @return [Integer] the approximated number of unique elements observed
      #   via {pfadd}.
      def pfcount(*keys)
        run(*keys.unshift(:PFCOUNT))
      end

      # Merge N different HyperLogLogs into a single one.
      # @see https://redis.io/commands/pfmerge
      #
      # @param [String] destkey
      # @param [String, Array<String>] sourcekeys
      #
      # @return [String] 'OK'
      def pfmerge(destkey, *sourcekeys)
        run(*sourcekeys.unshift(:PFMERGE, destkey))
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
oxblood-0.1.0 lib/oxblood/commands/hyper_log_log.rb
oxblood-0.1.0.dev12 lib/oxblood/commands/hyper_log_log.rb