0.03
No commit activity in last 3 years
No release in over 3 years
RedisScanner is a tiny tool for scanning redis's keys and creating statistic information. It scans keys using redis scan command and computing statistic result by key's pattern.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.11
~> 5.0
~> 10.0

Runtime

 Project Readme

RedisScanner Build Status

RedisScanner is a tiny tool for scanning all redis keys and creating statistic result. The features are the followings.

  • Scans keys using scan replacing keys command.
  • Creates statistic result by key's pattern.
  • Provide key's detail information which includes type and size.
  • Provide table format output..

Installation

Install redis_scanner in shell.

gem install redis_scanner

Installation prerequirement

You should install ruby first.

Usage

  • Get started

You can run it directly after install. It will scan local redis instance when you just input redis_scanner.

redis_scanner

The Output is like this:

+------------------------------------+-------+
| Key                                | Count |
+------------------------------------+-------+
| demo:user:<id>:counter             | 10000 |
| u:<uuid>:pf                        |    52 |
| sidekiq_demo:stat:failed:<date>    |     4 |
| sidekiq_demo:stat:processed:<date> |     4 |
| _sp_one:queue:default              |     1 |
| bh:queues                          |     1 |
...
+------------------------------------+-------+
redis_scanner -d -l 10

The Output is like this:

+------------------------------------+--------+-------+--------+---------+
| Key                                | Type   | Count | Size   | AvgSize |
+------------------------------------+--------+-------+--------+---------+
| demo:user:<id>:counter             | string | 10000 | 927510 |   92.75 |
| u:<uuid>:pf                        | hash   |    52 |    108 |    2.08 |
| sidekiq_demo:stat:failed:<date>    | string |     4 |      5 |    1.25 |
| sidekiq_demo:stat:processed:<date> | string |     4 |      6 |     1.5 |
| _sp_one:queue:default              | list   |     1 |      1 |     1.0 |
| bh:queues                          | set    |     1 |      1 |     1.0 |
| bh:retry                           | zset   |     1 |      1 |     1.0 |
| bh:stat:failed                     | string |     1 |      1 |     1.0 |
| bh:stat:processed                  | string |     1 |      1 |     1.0 |
| bus_app:app_two                    | hash   |     1 |      1 |     1.0 |
+------------------------------------+--------+-------+--------+---------+
  • Scan keys with some pattern
redis_scanner -m u:*
  • Output statistic result to a file
redis_scanner -f keys_stat.txt
  • Redis options. The options are same of redis-cli.
redis_scanner -h <host> -p <port> ...

Development

You are free to modify it for your need.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/xiewenwei/redis_scanner. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.