class Ravanello::Redis::Cursor
Redis
key cursor enumarable type
Constants
- KEYS_BATCH_SIZE
- SIZE_REGEX
Attributes
redis[R]
Public Class Methods
new(redis, limit: nil)
click to toggle source
# File lib/ravanello/redis/cursor.rb, line 15 def initialize(redis, limit: nil) @redis = redis @limit = limit end
Public Instance Methods
each() { |key(key, size(key))| ... }
click to toggle source
# File lib/ravanello/redis/cursor.rb, line 20 def each counter = 0 cursor = 0 while cursor != '0' cursor, keys = redis.scan(cursor, count: KEYS_BATCH_SIZE) keys.each do |key| break if !@limit.nil? && counter >= @limit counter += 1 yield(Key.new(key, size(key))) end end end
Private Instance Methods
size(key)
click to toggle source
# File lib/ravanello/redis/cursor.rb, line 35 def size(key) debug_data = redis.debug('object', key) SIZE_REGEX.match(debug_data)[1].to_i end