Skip to content

Instantly share code, notes, and snippets.

@HarlemSquirrel
Created June 14, 2023 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HarlemSquirrel/b5af94f603144ae1fc0c8aec702dce29 to your computer and use it in GitHub Desktop.
Save HarlemSquirrel/b5af94f603144ae1fc0c8aec702dce29 to your computer and use it in GitHub Desktop.
require "redis-client"
##
# Emulate the methods of the Redis gem for HealthMonitor
# so we can use RedisClient gem instead.
#
class HealthMonitorRedisClient
def initialize
# REDIS_CONNECTION_SETTINGS should be defined elsewhere
@client = RedisClient.config(**REDIS_CONNECTION_SETTINGS).new_client
end
def info
@client.call("INFO").then do |raw_info|
raw_info.each_line(chomp: true).with_object({}) do |line, info_hash|
next if line.blank? || line.start_with?("#")
key, value = line.split(":")
info_hash[key] = value
end
end
end
def get(key)
@client.call("GET", key)
end
def set(key, value)
@client.call("SET", key, value)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment