class HealthMonitor::Providers::Redis
Private Class Methods
configuration_class()
click to toggle source
# File lib/health_monitor/providers/redis.rb, line 23 def configuration_class ::HealthMonitor::Providers::Redis::Configuration end
Public Instance Methods
check!()
click to toggle source
# File lib/health_monitor/providers/redis.rb, line 28 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/health_monitor/providers/redis.rb, line 70 def bytes_to_megabytes(bytes) (bytes.to_f / 1024 / 1024).round end
check_max_used_memory!()
click to toggle source
# File lib/health_monitor/providers/redis.rb, line 48 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/health_monitor/providers/redis.rb, line 39 def check_values! time = Time.now.to_formatted_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/health_monitor/providers/redis.rb, line 55 def key @key ||= ['health', request.try(:remote_ip)].join(':') end
redis()
click to toggle source
# File lib/health_monitor/providers/redis.rb, line 59 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/health_monitor/providers/redis.rb, line 74 def used_memory_mb bytes_to_megabytes(redis.info['used_memory']) end