class DoctorStrange::Providers::Redis
Private Class Methods
configuration_class()
click to toggle source
# File lib/doctor_strange/providers/redis.rb, line 21 def configuration_class ::DoctorStrange::Providers::Redis::Configuration end
Public Instance Methods
check!()
click to toggle source
# File lib/doctor_strange/providers/redis.rb, line 26 def check! check_values! check_max_used_memory! rescue Exception => e raise RedisException.new(e.message) ensure redis.close end
Private Instance Methods
bytes_to_megabytes(bytes)
click to toggle source
# File lib/doctor_strange/providers/redis.rb, line 68 def bytes_to_megabytes(bytes) (bytes.to_f / 1024 / 1024).round end
check_max_used_memory!()
click to toggle source
# File lib/doctor_strange/providers/redis.rb, line 46 def check_max_used_memory! return unless configuration.max_used_memory return if used_memory_mb <= configuration.max_used_memory raise "#{used_memory_mb}Mb memory using is higher than #{configuration.max_used_memory}Mb maximum expected" end
check_values!()
click to toggle source
# File lib/doctor_strange/providers/redis.rb, line 37 def check_values! time = Time.now.to_s(:rfc2822) redis.set(key, time) fetched = redis.get(key) raise "different values (now: #{time}, fetched: #{fetched})" if fetched != time end
key()
click to toggle source
# File lib/doctor_strange/providers/redis.rb, line 53 def key @key ||= ['health', request.try(:remote_ip)].join(':') end
redis()
click to toggle source
# File lib/doctor_strange/providers/redis.rb, line 57 def redis @redis = if configuration.connection configuration.connection elsif configuration.url ::Redis.new(url: configuration.url) else ::Redis.new end end
used_memory_mb()
click to toggle source
# File lib/doctor_strange/providers/redis.rb, line 72 def used_memory_mb bytes_to_megabytes(redis.info['used_memory']) end