With this Ruby script you can print all values in a Redis database to your console (derived from this bash script Show archive.org snapshot ).
Note: Do not run this command in production. This is for debugging purposes only.
def pretty_print_redis(redis)
redis.keys.each_with_object({}) do |key, hash|
type = redis.type(key)
hash[key] = case type
when 'string'
redis.get(key)
when 'hash'
redis.hgetall(key)
when 'list'
redis.lrange(key, 0, -1)
when 'set'
redis.smembers(key)
when 'zset'
redis.zrange(key, 0, -1, with_scores: true)
else
raise ArgumentError, "Unknown type #{type}"
end
end
end
pretty_print_redis(Redis.new(host: "10.0.1.1", port: 6380, db: 15))
Posted by Emanuel to makandra dev (2023-07-10 13:27)