Class: RedisCopy::KeyEmitter::Default

Inherits:
Object
  • Object
show all
Includes:
RedisCopy::KeyEmitter
Defined in:
lib/redis-copy/key-emitter.rb

Overview

The default strategy blindly uses ‘redis.keys(’*‘)`

Instance Method Summary collapse

Methods included from RedisCopy::KeyEmitter

load, #to_s

Constructor Details

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

Returns a new instance of Default.



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/redis-copy/key-emitter.rb', line 39

def initialize(redis, ui, options = {})
  ui.abort unless ui.confirm? "    WARNING: \#{self} key emitter uses redis.keys('*') to\n    get its list of keys.\n\n    The redis keys command [reference](http://redis.io/commands/keys)\n    says this:\n\n    > Warning: consider KEYS as a command that should only be used\n    > in production environments with extreme care. It may ruin\n    > performance when it is executed against large databases.\n    > This command is intended for debugging and special operations,\n    > such as changing your keyspace layout. Don't use KEYS in your\n    > regular application code. If you're looking for a way to find\n    > keys in a subset of your keyspace, consider using sets.\n  EOWARNING\n  super\nend\n".strip_heredoc

Instance Method Details

#keysObject



58
59
60
61
# File 'lib/redis-copy/key-emitter.rb', line 58

def keys
  @ui.debug "REDIS: #{@redis.client.id} KEYS *"
  @redis.keys('*').to_enum
end