class Red
Constants
- REDIS_ERRORS
Attributes
redis[RW]
Public Class Methods
client_version()
click to toggle source
# File lib/redness/red.rb, line 17 def self.client_version @version ||= Redis::VERSION.scan(/\d+/).map { |s| s.to_i } end
delete(key)
click to toggle source
# File lib/redness/red.rb, line 21 def self.delete(key) redis.del(key) end
Public Instance Methods
execute_with_uncertainty(fail_return = []) { || ... }
click to toggle source
# File lib/redness/red.rb, line 29 def execute_with_uncertainty(fail_return = []) yield rescue *REDIS_ERRORS fail_return end
method_missing(method, *args)
click to toggle source
# File lib/redness/red.rb, line 49 def method_missing(method, *args) raise RedisUnavailable unless redis redis.send(method, *args) end
multi_with_caution(fail_return = [], &block)
click to toggle source
# File lib/redness/red.rb, line 35 def multi_with_caution(fail_return = [], &block) begin redis.multi(&block) || fail_return rescue Redis::TimeoutError # The redis client pipelines the commands internally. It's possible the # MULTI succeeds, but there's a timeout before reaching the EXEC. Try to # issue an extra discard to ensure the transaction is closed. redis.discard # may raise Redis::CommandError if MULTI never succeeded raise end rescue fail_return end
redis()
click to toggle source
# File lib/redness/red.rb, line 25 def redis Red.redis end