https://github.com/git-hulk/rdbtools
rdb parser tools for redis, implemented in C, use lua to format key-value.
https://github.com/git-hulk/rdbtools
Last synced: about 1 year ago
JSON representation
rdb parser tools for redis, implemented in C, use lua to format key-value.
- Host: GitHub
- URL: https://github.com/git-hulk/rdbtools
- Owner: git-hulk
- License: mit
- Archived: true
- Created: 2014-08-14T06:18:06.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2016-04-20T15:41:17.000Z (about 10 years ago)
- Last Synced: 2024-11-12T18:41:41.690Z (over 1 year ago)
- Language: C
- Homepage:
- Size: 684 KB
- Stars: 45
- Watchers: 6
- Forks: 14
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# rdbtools [](http://opensource.org/licenses/MIT)
A tool use c to analyze redis rdb file, and use lua to handle.
> Notice: This tools was tested on 2.2 , 2.4 , 2.6, 2.8
> bugs in other versions? open issues, I will fix it, thanks~
#### 1. What about this tool to do?
> use lua to parse rdb file to user's format data, like aof file, json etc.
#### 2. How to use?
```shell
$ cd rdbtools/src
$ make
$ ./rdbtools -f ../tests/dump2.4.rdb -s ../scripts/example.lua
```
NOTE: Compile error with readline.h is not found, just use yum or apt-get to install readline and readline-devel
#### 3. Options
```shell
USAGE: ./rdbtools [-f file] -V -h
-V --version
-h --help show usage
-f --file specify which rdb file would be parsed.
-s --file specify which lua script, default is ../scripts/example.lua
```
If you want to handle key-value in rdb file, you can use `-s your_script.lua`, and lua function `handle` will be callbacked.
Example can be found in `scripts/example.lua`, and it just print the key-value.
##### Json format example
`cat scripts/json_exapmle.lua`
```lua
local cjson = require "cjson"
function handle(item)
print(cjson.encode(item))
end
```
And result is below:

#### 4. Params in handle function
```lua
function handle(item)
--item.type, value may be string, set, zset, list, or hash.
--item.expire_time, key expire time .
--item.value, may be string or list or hash, it depends on item.type
end
```
#### 5. Environment
If you what to know rdb version and which db is selcted.
```lua
print(env.version)
print(env.db_num)
```
#### 6. Contact me?
> ```Sina Weibo```: [@改名hulk](http://www.weibo.com/tianyi4)
>```Gmail```: [hulk.website@gmail.com](mailto:hulk.website@gmail.com)
>```Blog```: [www.hulkdev.com](http://www.hulkdev.com)
any bugs? send mail, and I will appreciate your help.