class OkComputer::GenericCacheCheck
Verifies that Rails can write to and read from its cache.
Public Instance Methods
check()
click to toggle source
Public: Check
whether cache can be written to and read from
# File lib/ok_computer/built_in_checks/generic_cache_check.rb, line 7 def check test_value.tap do |value| Rails.cache.write(cache_key, value) if value == Rails.cache.read(cache_key) mark_message "Able to read and write via #{humanize_cache_store_name}" else mark_failure mark_message "Value read from the cache does not match the value written" end end rescue => error mark_failure mark_message "Connection failure: #{error}" end
Private Instance Methods
cache_key()
click to toggle source
# File lib/ok_computer/built_in_checks/generic_cache_check.rb, line 29 def cache_key "ock-generic-cache-check-#{Socket.gethostname}" end
humanize_cache_store_name()
click to toggle source
# File lib/ok_computer/built_in_checks/generic_cache_check.rb, line 33 def humanize_cache_store_name name = if Rails.application.config.cache_store.is_a? Array Rails.application.config.cache_store[0] else Rails.application.config.cache_store end name.to_s.humanize end
test_value()
click to toggle source
Private: Generate a unique value each time we check
# File lib/ok_computer/built_in_checks/generic_cache_check.rb, line 25 def test_value SecureRandom.hex end