Class: Red
- Inherits:
-
Object
show all
- Defined in:
- lib/redness/red.rb
Defined Under Namespace
Classes: RedisUnavailable
Class Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
42
43
44
45
|
# File 'lib/redness/red.rb', line 42
def method_missing(method, *args)
raise RedisUnavailable unless redis
redis.send(method, *args)
end
|
Class Attribute Details
.redis ⇒ Object
Returns the value of attribute redis.
7
8
9
|
# File 'lib/redness/red.rb', line 7
def redis
@redis
end
|
Class Method Details
.client_version ⇒ Object
10
11
12
|
# File 'lib/redness/red.rb', line 10
def self.client_version
@version ||= Redis::VERSION.scan(/\d+/).map { |s| s.to_i }
end
|
.delete(key) ⇒ Object
14
15
16
|
# File 'lib/redness/red.rb', line 14
def self.delete(key)
redis.del(key)
end
|
Instance Method Details
#execute_with_uncertainty(fail_return = []) ⇒ Object
22
23
24
25
26
|
# File 'lib/redness/red.rb', line 22
def execute_with_uncertainty(fail_return = [])
yield
rescue RedisUnavailable, Redis::CannotConnectError, Redis::TimeoutError
fail_return
end
|
#multi_with_caution(fail_return = [], &block) ⇒ Object
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/redness/red.rb', line 28
def multi_with_caution(fail_return = [], &block)
begin
redis.multi(&block) || fail_return
rescue Redis::TimeoutError
redis.discard raise
end
rescue
fail_return
end
|
#redis ⇒ Object
18
19
20
|
# File 'lib/redness/red.rb', line 18
def redis
Red.redis
end
|