Created
April 3, 2017 00:59
-
-
Save jasoares/ab5fd915ccc9e90d208b1ad310f57655 to your computer and use it in GitHub Desktop.
Redis Contents Describer
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
$redis = Redis.new | |
keys = $redis.keys('*') | |
keys_with_values = keys.inject({}) do |kwv, key| | |
type = $redis.type(key) | |
value = $redis.get(key) if type == 'string' | |
value = $redis.scard(key) if type == 'set' | |
value = $redis.hkeys(key) if type == 'hash' | |
value = $redis.llen(key) if type == 'list' | |
value = $redis.zcard(key) if type == 'zset' | |
kwv[key] = { type: type, value: value } | |
kwv | |
end | |
ap keys_with_values.sort { |(k1, v1), (k2, v2)| v1[:type] <=> v2[:type] } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment