module RedisCluster::Function::Scan

Scan is a collection of redis scan functions

Constants

HSCAN
ZSCAN

Public Instance Methods

hscan(key, cursor, options = {}) click to toggle source

Scan a hash

@example Retrieve the first batch of key/value pairs in a hash

redis.hscan("hash", 0)

@param [String, Integer] cursor the cursor of the iteration @param [Hash] options

- `:match => String`: only return keys matching the pattern
- `:count => Integer`: return count keys at most per iteration

@return [String, Array<[String, String]>] the next cursor and all found keys

# File lib/redis_cluster/function/scan.rb, line 44
def hscan(key, cursor, options = {})
  args = [:hscan, key, cursor]
  args.push('MATCH', options[:match]) if options[:match]
  args.push('COUNT', options[:count]) if options[:count]

  call(key, args, transform: HSCAN, read: true)
end
sscan(key, cursor, options = {}) click to toggle source

Scan a set

@example Retrieve the first batch of keys in a set

redis.sscan("set", 0)

@param [String, Integer] cursor the cursor of the iteration @param [Hash] options

- `:match => String`: only return keys matching the pattern
- `:count => Integer`: return count keys at most per iteration

@return [String, Array<String>] the next cursor and all found members

# File lib/redis_cluster/function/scan.rb, line 63
def sscan(key, cursor, options = {})
  args = [:sscan, key, cursor]
  args.push('MATCH', options[:match]) if options[:match]
  args.push('COUNT', options[:count]) if options[:count]

  call(key, args, read: true)
end
zscan(key, cursor, options = {}) click to toggle source

Scan a sorted set

@example Retrieve the first batch of key/value pairs in a hash

redis.zscan("zset", 0)

@param [String, Integer] cursor the cursor of the iteration @param [Hash] options

- `:match => String`: only return keys matching the pattern
- `:count => Integer`: return count keys at most per iteration

@return [String, Array<[String, Float]>] the next cursor and all found

members and scores
# File lib/redis_cluster/function/scan.rb, line 25
def zscan(key, cursor, options = {})
  args = [:zscan, key, cursor]
  args.push('MATCH', options[:match]) if options[:match]
  args.push('COUNT', options[:count]) if options[:count]

  call(key, args, transform: ZSCAN, read: true)
end