How to view my Redis current_size database?

I know about redis-cli, info and config commands. However, they have nothing to indicate the size of the current database. How could I figure that out?

+16
redis
source share
4 answers

Using the INFO Command. more details here: http://redis.io/commands/info

sample output:

 redis-cli redis 127.0.0.1:6379> info redis_version:2.4.11 redis_git_sha1:00000000 redis_git_dirty:0 arch_bits:64 multiplexing_api:kqueue gcc_version:4.2.1 process_id:300 uptime_in_seconds:1389779 uptime_in_days:16 lru_clock:1854465 used_cpu_sys:59.86 used_cpu_user:73.02 used_cpu_sys_children:0.15 used_cpu_user_children:0.11 connected_clients:1 connected_slaves:0 client_longest_output_list:0 client_biggest_input_buf:0 blocked_clients:0 used_memory:1329424 used_memory_human:1.27M used_memory_rss:2285568 used_memory_peak:1595680 used_memory_peak_human:1.52M mem_fragmentation_ratio:1.72 mem_allocator:libc loading:0 aof_enabled:0 changes_since_last_save:0 bgsave_in_progress:0 last_save_time:1360719404 bgrewriteaof_in_progress:0 total_connections_received:221 total_commands_processed:29926 expired_keys:2 evicted_keys:0 keyspace_hits:1678 keyspace_misses:3 pubsub_channels:0 pubsub_patterns:0 latest_fork_usec:379 vm_enabled:0 role:master db0:keys=23,expires=0 
+28
source share

You can use the following command to list the databases for which some keys are defined:

 INFO keyspace # Keyspace db0:keys=6002,expires=0,avg_ttl=0 db9:keys=20953296,expires=0,avg_ttl=0 db10:keys=1,expires=0,avg_ttl=0 

You can also use Select 0 or Select 1 or any db you want to check with the current size. After selecting db Use the dbsize command to display the size of the selected db.

 Select 9 OK dbsize (integer) 20953296 

to list general information of your type redis info and to view only memory just enter

 INFO Memory # Memory used_memory:1259920 used_memory_human:1.20M used_memory_rss:1227000 used_memory_peak:2406152 used_memory_peak_human:2.29M used_memory_lua:36864 mem_fragmentation_ratio:0.97 mem_allocator:dlmalloc-2.8 
+8
source share

Use the dbsize command to get the number of keys in the database

+2
source share

You can also do this with a single line command:

 redis-cli -p 6379 -a password info| egrep "used_memory_human|total_system_memory_human" 

This will display the total amount of memory used by Redis and the total amount of RAM on the server.

+1
source share

All Articles