{"id":16931953,"url":"https://github.com/catcherwong/rdb-tools","last_synced_at":"2025-07-13T07:33:30.470Z","repository":{"id":39889074,"uuid":"466379569","full_name":"catcherwong/rdb-tools","owner":"catcherwong","description":"⚡ An analysis tool of the Redis/Valkey RDB files, which includes library and CLI.","archived":false,"fork":false,"pushed_at":"2024-10-07T05:07:16.000Z","size":591,"stargazers_count":58,"open_issues_count":2,"forks_count":12,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-28T23:03:50.417Z","etag":null,"topics":["analysis","cli","csharp","library","memory","rdb","redis","valkey"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/catcherwong.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-03-05T07:13:41.000Z","updated_at":"2025-03-19T07:35:11.000Z","dependencies_parsed_at":"2023-11-17T02:29:50.265Z","dependency_job_id":"bb0ea6b5-f6d8-4a52-a07c-738983f791d9","html_url":"https://github.com/catcherwong/rdb-tools","commit_stats":{"total_commits":74,"total_committers":3,"mean_commits":"24.666666666666668","dds":"0.027027027027026973","last_synced_commit":"f17e120a339387c8706f581221f19b91777509f3"},"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/catcherwong%2Frdb-tools","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/catcherwong%2Frdb-tools/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/catcherwong%2Frdb-tools/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/catcherwong%2Frdb-tools/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/catcherwong","download_url":"https://codeload.github.com/catcherwong/rdb-tools/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247266562,"owners_count":20910836,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["analysis","cli","csharp","library","memory","rdb","redis","valkey"],"created_at":"2024-10-13T20:45:07.417Z","updated_at":"2025-04-05T00:05:32.727Z","avatar_url":"https://github.com/catcherwong.png","language":"C#","funding_links":[],"categories":["C# #"],"sub_categories":[],"readme":"# rdb-tools\n\n`rdb-tools` is a tool to parse/analysis [Redis](https://redis.io/)/[Valkey](https://valkey.io/) rdb files that is implemented by csharp.\n\nThis repository is inspired by [redis-rdb-tools](https://github.com/sripathikrishnan/redis-rdb-tools) and [rdr](https://github.com/xueqiu/rdr).\n\nIt consists of two parts:\n\n- A parser library, that you can customize by yourself.\n- An anslysis cli tool, that your can ans some basic usages for command line.\n\n## rdb-cli\n\n### Install\n\n1. Download the package from the [latest stable release](https://github.com/catcherwong/rdb-tools/releases).\n2. `dotnet tool install --global rdb-cli`\n\n### Usage\n\nShow help information:\n\n```\n[~] ./rdb-cli -h      \nDescription:\n  rdb-cli is a command line tool, analysis redis/valkey rdb files.\n\nUsage:\n  rdb-cli [command] [options]\n\nOptions:\n  -?, -h, --help  Show help and usage information\n  -v, --version   Show version information\n\nCommands:\n  keys \u003cfile\u003e    Get all keys from rdb files\n  memory \u003cfile\u003e  Get memory info from rdb files\n  test \u003cfile\u003e    Try to parser rdb files without operation\n  csv \u003cfile\u003e     Convert rdb file to csv.\n```\n\nThe usage of `memory` is as follow:\n\n```\n[~] ./rdb-cli memory -h\nDescription:\n  Analysis memory info from rdb files\n\nUsage:\n  rdb-cli memory \u003cfile\u003e [options]\n\nArguments:\n  \u003cfile\u003e  The path of rdb file.\n\nOptions:\n  -o, --output \u003coutput\u003e                                  The output path of parsing result.\n  -ot, --output-type \u003ccsv|html|json\u003e                     The output type of parsing result. [default: json]\n  -tp, --top-prefixes \u003ctop-prefixes\u003e                     The number of top key prefixes. [default: 50]\n  -tb, --top-bigkeys \u003ctop-bigkeys\u003e                       The number of top big keys. [default: 50]\n  --db \u003cdb\u003e                                              The filter of redis databases.\n  --type \u003chash|list|module|set|sortedset|stream|string\u003e  The filter of redis types.\n  --key-prefix \u003ckey-prefix\u003e                              The filter of redis key prefix.\n  --separators \u003cseparators\u003e                              The separators of redis key prefix.\n  --sep-count \u003csep-count\u003e                                The count of separating a key to prefix.\n  --permanent                                            Whether the key is permanent.\n  --ignore-fole                                          Whether ignore the field of largest elem.\n  --key-suffix-enable                                    Use the key suffix as the key prefix.\n  --cdn \u003ccdn\u003e                                            The cdn domain for html output [default: unpkg.com]\n  -?, -h, --help                                         Show help and usage information\n```\n\n```\n[~] ./rdb-cli memory /tmp/demo.rdb -ot html -tb 200\n\nPrepare to parse [/tmp/demo.rdb]\nPlease wait for a moment...\n\nparse cost: 22449ms\ntotal cost: 23107ms\nresult path: /tmp/res.html\n```\n\nSample html result is as follow:\n\n![](./static/memsample.png)\n\nSample json result is as follow:\n\n```json\n{\n    \"usedMem\": 2373094496,\n    \"cTime\": 0,\n    \"count\": 7615333,\n    \"rdbVer\": 9,\n    \"redisVer\": \"5.2.0\",\n    \"redisType\": \"Redis\",\n    \"redisBits\": 13366,\n    \"typeRecords\": [\n        {\n            \"Type\": \"sortedset\",\n            \"Bytes\": 1385664695,\n            \"Num\": 6212084\n        }\n    ],\n    \"largestRecords\": [\n        {\n            \"Database\": 2,\n            \"Key\": \"key\",\n            \"Bytes\": 10340,\n            \"Type\": \"string\",\n            \"Encoding\": \"string\",\n            \"Expiry\": 0,\n            \"NumOfElem\": 8318,\n            \"LenOfLargestElem\": 0,\n            \"FieldOfLargestElem\": null,\n            \"Idle\": 0,\n            \"Freq\": 0\n        }\n     ],\n     \"largestKeyPrefix\": [\n        {\n            \"Type\": \"string\",\n            \"Prefix\": \"key4\",\n            \"Bytes\": 116,\n            \"Num\": 1,\n            \"Elements\": 2\n        }\n    ],\n    \"expiryInfo\": [\n        {\n            \"Expiry\": \"0~1h\",\n            \"Bytes\": 986801692,\n            \"Num\": 4345021\n        }\n    ],\n    \"idleOrFreqInfo\": [\n        {\n            \"Category\": \"0~50\",\n            \"Bytes\":1,\n            \"Num\":1\n        }\n    ],\n    \"functions\": [\n        {\n            \"Engine\": \"lua\",\n            \"LibraryName\": \"mylib\"\n        }\n    ],\n    \"largestStreams\": [\n        {\n            \"Key\": \"key\",\n            \"Length\": 5,\n            \"LastId\": \"1650158935767-0\",\n            \"FirstId\": \"1650158906951-0\",\n            \"MaxDeletedEntryId\": \"0-0\",\n            \"EntriesAdded\": 5,\n            \"CGroups\": 0\n        }\n    ],\n    \"dbInfo\": [\n        {\n            \"DB\": \"db0\",\n            \"Bytes\": 116,\n            \"Num\": 1\n        }\n    ]\n}\n````\n\n## RDBParse\n\n### Install\n\n`dotnet add package RDBParse`\n\n### Usage\n\n1. Implement your own `IReaderCallback`\n2. Create a new instance of `BinaryReaderRDBParser`\n3. Call **Parse** method of `BinaryReaderRDBParser` instance\n\n\nFollowing this below code for example.\n\n```cs\npublic class MyReaderCallBack : IReaderCallback\n{\n}\n```\n\n```cs\nvar path = \"/yourpath/your.rdb\"\nvar cb = new MyReaderCallBack();\nvar parser = new RDBParser.BinaryReaderRDBParser(cb);\nparser.Parse(path);\n```\n\n## To contribute\n\nContributions are welcome!","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcatcherwong%2Frdb-tools","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcatcherwong%2Frdb-tools","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcatcherwong%2Frdb-tools/lists"}