Class: OkComputer::GenericCacheCheck

Inherits:
Check
  • Object
show all
Defined in:
lib/ok_computer/built_in_checks/generic_cache_check.rb

Overview

Verifies that Rails can write to and read from its cache.

Constant Summary

Constants inherited from Check

Check::CheckNotDefined

Instance Attribute Summary

Attributes inherited from Check

#failure_occurred, #message, #registrant_name, #time

Instance Method Summary collapse

Methods inherited from Check

#<=>, #clear, #mark_failure, #mark_message, #run, #success?, #to_json, #to_text, #with_benchmarking

Instance Method Details

#checkObject

Public: Check whether cache can be written to and read from



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# 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