Class: OkComputer::CacheCheck
- Defined in:
- lib/ok_computer/built_in_checks/cache_check.rb
Constant Summary collapse
- ConnectionFailed =
Class.new(StandardError)
Constants inherited from Check
OkComputer::Check::CheckNotDefined
Instance Attribute Summary
Attributes inherited from Check
#failure_occurred, #message, #registrant_name
Instance Method Summary collapse
-
#check ⇒ Object
Public: Check whether the cache is active.
-
#stats ⇒ Object
Public: Outputs stats string for cache.
Methods inherited from Check
#clear, #mark_failure, #mark_message, #run, #success?, #to_json, #to_text
Instance Method Details
#check ⇒ Object
Public: Check whether the cache is active
7 8 9 10 11 12 |
# File 'lib/ok_computer/built_in_checks/cache_check.rb', line 7 def check "Cache is available (#{stats})" rescue ConnectionFailed => e mark_failure "Error: '#{e}'" end |
#stats ⇒ Object
Public: Outputs stats string for cache
15 16 17 18 19 20 21 22 23 |
# File 'lib/ok_computer/built_in_checks/cache_check.rb', line 15 def stats stats = Rails.cache.stats host = stats.select{|k,v| k =~ Regexp.new(Socket.gethostname) }.values[0] mem_used = to_megabytes host['bytes'] mem_max = to_megabytes host['limit_maxbytes'] return "#{mem_used} / #{mem_max} MB, #{stats.count - 1} peers" rescue => e raise ConnectionFailed, e end |