Skip to content
This repository has been archived by the owner on May 9, 2022. It is now read-only.
/ rdbtools Public archive

rdb parser tools for redis, implemented in C, use lua to format key-value.

License

Notifications You must be signed in to change notification settings

git-hulk/rdbtools

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rdbtools Build Status

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?

$ 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

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

local cjson = require "cjson"

function handle(item)
     print(cjson.encode(item))
end     

And result is below: image

4. Params in handle function

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.

print(env.version)
print(env.db_num)

6. Contact me?

Sina Weibo: @改名hulk

Gmail: hulk.website@gmail.com

Blog: www.hulkdev.com

any bugs? send mail, and I will appreciate your help.

About

rdb parser tools for redis, implemented in C, use lua to format key-value.

Resources

License

Stars

Watchers

Forks

Packages

No packages published