How to check memory used by all the keys in redis-server.
I have started redis-server
with appendonly yes
option. To check size of an individual key I am using following commands-
127.0.0.1:6379> set foo bar
OK
127.0.0.1:6379> memory usage foo
(integer) 50
How do I get memory usage of all the existing keys in redis
You can find this information using the following command:
INFO memory
This will return detailed information about the memory usage and you can find the value:
used_memory_dataset
: The size in bytes of the datasetYou also have interesting values using the MEMORY STATS
command, including the one describe above dataset.bytes
and the total number of keys keys.count
.
Also and probably my favorite approach, when I work with Redis I am using Redis Insight to look at all the metrics during development.
Regards