lib/redis.rb in redis-3.1.0 vs lib/redis.rb in redis-3.2.0

- old
+ new

@@ -1586,10 +1586,42 @@ synchronize do |client| client.call([:zremrangebyrank, key, start, stop]) end end + # Return a range of members with the same score in a sorted set, by lexicographical ordering + # + # @example Retrieve members matching a + # redis.zrangebylex("zset", "[a", "[a\xff") + # # => ["aaren", "aarika", "abagael", "abby"] + # @example Retrieve the first 2 members matching a + # redis.zrangebylex("zset", "[a", "[a\xff", :limit => [0, 2]) + # # => ["aaren", "aarika"] + # + # @param [String] key + # @param [String] min + # - inclusive minimum is specified by prefixing `(` + # - exclusive minimum is specified by prefixing `[` + # @param [String] max + # - inclusive maximum is specified by prefixing `(` + # - exclusive maximum is specified by prefixing `[` + # @param [Hash] options + # - `:limit => [offset, count]`: skip `offset` members, return a maximum of + # `count` members + # + # @return [Array<String>, Array<[String, Float]>] + def zrangebylex(key, min, max, options = {}) + args = [] + + limit = options[:limit] + args.concat(["LIMIT"] + limit) if limit + + synchronize do |client| + client.call([:zrangebylex, key, min, max] + args) + end + end + # Return a range of members in a sorted set, by score. # # @example Retrieve members with score `>= 5` and `< 100` # redis.zrangebyscore("zset", "5", "(100") # # => ["a", "b"] @@ -2447,14 +2479,17 @@ end end # Get the approximate cardinality of members added to HyperLogLog structure. # - # @param [String] key + # If called with multiple keys, returns the approximate cardinality of the + # union of the HyperLogLogs contained in the keys. + # + # @param [String, Array<String>] keys # @return [Fixnum] - def pfcount(key) + def pfcount(*keys) synchronize do |client| - client.call([:pfcount, key]) + client.call([:pfcount] + keys) end end # Merge multiple HyperLogLog values into an unique value that will approximate the cardinality of the union of # the observed Sets of the source HyperLogLog structures.