Created
June 14, 2023 14:14
-
-
Save HarlemSquirrel/b5af94f603144ae1fc0c8aec702dce29 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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