Module: RedisCopy::KeyEmitter

Extended by:
Implements::Interface
Defined in:
lib/redis-copy/key-emitter.rb

Overview

A Key emitter emits keys. This is built to be an abstraction on top of redis.keys(‘*’) (implemented by RedisCopy::KeyEmitter::Default), but should allow smarter implementations to be built that can handle billion-key dbs without blocking on IO.

Defined Under Namespace

Classes: Keys, Scan

Instance Method Summary collapse

Instance Method Details

#dbsizeObject



31
32
33
# File 'lib/redis-copy/key-emitter.rb', line 31

def dbsize
  @redis.dbsize
end

#initialize(redis, ui, options = {}) ⇒ Object

Parameters:

  • redis (Redis)
  • options (Hash<Symbol:String>) (defaults to: {})

Options Hash (options):

  • :pattern (String) — default: '*'


15
16
17
18
19
# File 'lib/redis-copy/key-emitter.rb', line 15

def initialize(redis, ui, options = {})
  @redis    = redis
  @ui       = ui
  @options  = options
end

#keysEnumerable<String>

Returns:

  • (Enumerable<String>)

Raises:

  • (NotImplementedError)


22
23
24
25
# File 'lib/redis-copy/key-emitter.rb', line 22

def keys
  return super if defined?(super)
  raise NotImplementedError
end

#patternObject



27
28
29
# File 'lib/redis-copy/key-emitter.rb', line 27

def pattern
  @pattern ||= @options.fetch(:pattern) { '*' }
end

#to_sObject



35
36
37
# File 'lib/redis-copy/key-emitter.rb', line 35

def to_s
  self.class.name.demodulize
end