Class: Amnesia::Host
- Inherits:
-
Object
show all
- Defined in:
- lib/amnesia/host.rb
Instance Method Summary
collapse
Constructor Details
#initialize(address) ⇒ Host
Returns a new instance of Host.
3
4
5
|
# File 'lib/amnesia/host.rb', line 3
def initialize(address)
@address = address
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
13
14
15
|
# File 'lib/amnesia/host.rb', line 13
def method_missing(method, *args)
stats[method.to_s.to_sym].sum if stats.has_key? method.to_s.to_sym
end
|
Instance Method Details
#address ⇒ Object
24
25
26
|
# File 'lib/amnesia/host.rb', line 24
def address
@address || @connection.servers.join(', ')
end
|
#alive? ⇒ Boolean
7
8
9
10
11
|
# File 'lib/amnesia/host.rb', line 7
def alive?
return true if connection.stats
rescue Memcached::Error
return false
end
|
#stats ⇒ Object
17
18
19
20
21
22
|
# File 'lib/amnesia/host.rb', line 17
def stats
connection.stats[connection.stats.keys.first]
connection.stats
rescue Memcached::Error
return {}
end
|