Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do i view my Redis database current_size?

Tags:

redis

I am aware of redis-cli, and the info and config commands. However, they do not have anything that states the size of the current database. How could I figure this out?

like image 402
Kamilski81 Avatar asked Feb 13 '13 00:02

Kamilski81


People also ask

How do I view Redis database?

You can check the actual number by running redis-cli config get databases. In interactive mode, the database number is displayed in the prompt within square braces. For example, 127.0. 0.1:6379[13] shows that the 13th database is in use.

How do I access Redis config file?

The Redis configuration file is located at installdir/redis/etc/redis. conf.

How do I find my Redis database name?

There is no command to do it (like you would do it with MySQL for instance). The number of Redis databases is fixed, and set in the configuration file. By default, you have 16 databases. Each database is identified by a number (not a name).

How do I check disk space in Redis?

Redis Key Memory Info You can use two main commands if you want to view the keys in a Redis datastore. Dbsize – The Redis dbsize command shows the total number of valid keys in a specific database. Info keyspace – This command shows the keys in each database available in the Redis cluster.


2 Answers

Using the INFO command. full 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 
like image 68
Pascal Belloncle Avatar answered Sep 23 '22 20:09

Pascal Belloncle


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 which you want to check with the current size. After selection of db Use dbsize command to display the size of selected db.

Select 9 OK dbsize (integer) 20953296 

for listing overall information of your redis type info and to view only memory just type

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 
like image 24
Aswin 1054 Avatar answered Sep 23 '22 20:09

Aswin 1054