Sha256: 2e1b937371e1554ee636aff10a6d45c8652c5b6bf9c094c87212623f91b2de95

Contents?: true

Size: 1.2 KB

Versions: 4

Compression:

Stored size: 1.2 KB

Contents

# frozen_string_literal: true

# Released under the MIT License.
# Copyright, 2019-2023, by Samuel Williams.

module Protocol
	module Redis
		module Methods
			module Counting
				# Adds the specified elements to the specified HyperLogLog. O(1) to add every element.
				# @see https://redis.io/commands/pfadd
				# @param key [Key]
				# @param element [String]
				def pfadd(key, element, *elements)
					call("PFADD", key, element, *elements)
				end
				
				# Return the approximated cardinality of the set(s) observed by the HyperLogLog at key(s). O(1) with a very small average constant time when called with a single key. O(N) with N being the number of keys, and much bigger constant times, when called with multiple keys.
				# @see https://redis.io/commands/pfcount
				# @param key [Key]
				def pfcount(key, *keys)
					call("PFCOUNT", key, *keys)
				end
				
				# Merge N different HyperLogLogs into a single one. O(N) to merge N HyperLogLogs, but with high constant times.
				# @see https://redis.io/commands/pfmerge
				# @param destkey [Key]
				# @param sourcekey [Key]
				def pfmerge(destkey, sourcekey, *sourcekeys)
					call("PFMERGE", destkey, sourcekey, *sourcekeys)
				end
			end
		end
	end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
protocol-redis-0.9.0 lib/protocol/redis/methods/counting.rb
protocol-redis-0.8.1 lib/protocol/redis/methods/counting.rb
protocol-redis-0.8.0 lib/protocol/redis/methods/counting.rb
protocol-redis-0.7.0 lib/protocol/redis/methods/counting.rb