Last active
December 4, 2021 10:46
-
-
Save niko/8df131e55839c7a68f029f74d9740ab0 to your computer and use it in GitHub Desktop.
Calculate Redis space usage by (colon separated) key space
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
# PREFIX='' ; redis-cli -n 15 keys "${PREFIX}*" | sed s/^"${PREFIX}:"// | awk -F ":" '{print $1}' | sort | uniq | while read KEYSPACE; do echo -n "${PREFIX}${PREFIX:+:}${KEYSPACE}: "; redis-cli -n 15 keys "${PREFIX}${PREFIX:+:}${KEYSPACE}:*" | while read k; do redis-cli -n 15 MEMORY USAGE $k; done | awk '{s+=$1}END{print NR,s}'; done | |
buffer: 11 56752046 | |
buffer_queue: 2 0 | |
ice: 29126 1063022045 | |
cast: 9705 12145987 | |
meta_player: 1 1297 | |
metrics: 23 2067 | |
stations: 9 1462399 | |
vast: 47 253390184 | |
# PREFIX='vast' ; redis-cli -n 15 keys "${PREFIX}*" | sed s/^"${PREFIX}:"// | awk -F ":" '{print $1}' | sort | uniq | while read KEYSPACE; do echo -n "${PREFIX}${PREFIX:+:}${KEYSPACE}: "; redis-cli -n 15 keys "${PREFIX}${PREFIX:+:}${KEYSPACE}:*" | while read k; do redis-cli -n 15 MEMORY USAGE $k; done | awk '{s+=$1}END{print NR,s}'; done | |
vast:media: 19 9170282 | |
vast:tracking_links: 9 27525 | |
vast:tracking_props: 11 4758 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment