-
-
Save zautomata/7876eb5dfcdfdb9f8d4091f7979674d6 to your computer and use it in GitHub Desktop.
Export data from redis to a plain text files
This file contains hidden or 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
| #!/usr/bin/env ruby | |
| require "redis" | |
| redis = Redis.new | |
| redis.keys("*").each do |key| | |
| val = case redis.type(key) | |
| when "string" | |
| redis.get key | |
| when "list" | |
| redis.lrange key, 0, -1 | |
| when "hash" | |
| redis.hgetall key | |
| when "set" | |
| redis.smembers key | |
| when "sortedset" | |
| redis.zrange key, 0, -1 | |
| else | |
| "unknown" | |
| end | |
| puts "#{key}: #{val}" | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment