Class: RedisCopy::Strategy::New
- Inherits:
-
Object
- Object
- RedisCopy::Strategy::New
- Includes:
- RedisCopy::Strategy
- Defined in:
- lib/redis-copy/strategy/new.rb
Class Method Summary collapse
Instance Method Summary collapse
Methods included from RedisCopy::Strategy
Class Method Details
.compatible?(redis) ⇒ Boolean
23 24 25 26 27 28 29 |
# File 'lib/redis-copy/strategy/new.rb', line 23 def self.compatible?(redis) maj, min, *_ = redis.info['redis_version'].split('.').map(&:to_i) return false unless maj >= 2 return false unless min >= 6 return true end |
Instance Method Details
#copy(key) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/redis-copy/strategy/new.rb', line 8 def copy(key) ttl = @src.ttl(key) # TTL returns seconds, -1 means none set # RESTORE ttl is in miliseconds, 0 means none set translated_ttl = (ttl && ttl > 0) ? (ttl * 1000) : 0 dumped_value = @src.dump(key) @dst.restore(key, translated_ttl, dumped_value) return true rescue Redis::CommandError => error @ui.debug("ERROR: #{error}") return false end |