Method: Redis::Commands::SortedSets#zrangebylex

Defined in:
lib/redis/commands/sorted_sets.rb

#zrangebylex(key, min, max, limit: nil) ⇒ Array<String>, Array<[String, Float]>

Return a range of members with the same score in a sorted set, by lexicographical ordering

Examples:

Retrieve members matching a

redis.zrangebylex("zset", "[a", "[a\xff")
  # => ["aaren", "aarika", "abagael", "abby"]

Retrieve the first 2 members matching a

redis.zrangebylex("zset", "[a", "[a\xff", :limit => [0, 2])
  # => ["aaren", "aarika"]

Parameters:

  • key (String)
  • min (String)
    • inclusive minimum is specified by prefixing ‘(`

    • exclusive minimum is specified by prefixing ‘[`

  • max (String)
    • inclusive maximum is specified by prefixing ‘(`

    • exclusive maximum is specified by prefixing ‘[`

  • options (Hash)
    • ‘:limit => [offset, count]`: skip `offset` members, return a maximum of

    ‘count` members

Returns:

  • (Array<String>, Array<[String, Float]>)


468
469
470
471
472
473
474
475
476
477
# File 'lib/redis/commands/sorted_sets.rb', line 468

def zrangebylex(key, min, max, limit: nil)
  args = [:zrangebylex, key, min, max]

  if limit
    args << "LIMIT"
    args.concat(limit.map { |l| Integer(l) })
  end

  send_command(args)
end