Last active
March 27, 2019 03:37
-
-
Save chenset/04deebb8274a55b11a1dc14a9ffacf90 to your computer and use it in GitHub Desktop.
redis memory usage per key
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 bash | |
| redis_cmd='redis-cli -n 1' | |
| # size of db | |
| ssss=0 | |
| # get keys and sizes | |
| for k in `$redis_cmd keys "*"`; do | |
| key_size_bytes=`$redis_cmd memory usage $k`; | |
| ((ssss+=key_size_bytes)) | |
| #if [ $key_size_bytes -gt 1024000 ] | |
| #then | |
| echo $k "===" $key_size_bytes; | |
| #fi | |
| done | |
| echo "" | |
| echo "db size: " $ssss; |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
redis version >= 4.0