MCPcopy Index your code
hub / github.com/CodisLabs/redis-port

github.com/CodisLabs/redis-port @v1.2.1

Chat with this repo
repository ↗ · DeepWiki ↗ · release v1.2.1 ↗ · + Follow
332 symbols 865 edges 28 files 14 documented · 4% updated 8y agov2.0-beta · 2018-04-27★ 63719 open issues
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

redis-port

Build Status

parse redis rdb file, sync data between redis master and slave

  • DECODE dumped payload to human readable format (hex-encoding)
redis-port decode    [--ncpu=N] [--parallel=M] \
    [--input=INPUT] \
    [--output=OUTPUT]
  • RESTORE rdb file to target redis
redis-port restore   [--ncpu=N] [--parallel=M] \
    [--input=INPUT]  [--faketime=FAKETIME] [--extra] [--filterdb=DB] \
     --target=TARGET [--auth=AUTH] [--redis|--codis]
  • DUMP rdb file from master redis
redis-port dump      [--ncpu=N] [--parallel=M] \
     --from=MASTER   [--password=PASSWORD] [--extra] \
    [--output=OUTPUT]
  • SYNC data from master to slave
redis-port sync      [--ncpu=N] [--parallel=M] \
     --from=MASTER   [--password=PASSWORD] [--psync] [--filterdb=DB] \
     --target=TARGET [--auth=AUTH] [--redis|--codis] [--sockfile=FILE [--filesize=SIZE]]

Options

  • -n N, --ncpu=N

set runtime.GOMAXPROCS to N

  • -p M, --parallel=M

set number of parallel routines

  • -i INPUT, --input=INPUT

use INPUT as input file, or if it is not given, redis-port reads from stdin (means '/dev/stdin')

  • -o OUTPUT, --output=OUTPUT

use OUTPUT as output file, or if it is not given, redis-port writes to stdout (means '/dev/stdout')

  • -m MASTER, --master=MASTER

specify the master redis

  • -t TARGET, --target=TARGET

specify the slave redis (or target redis)

  • -P PASSWORD, --password=PASSWORD

specify the redis auth password

  • -A AUTH, --auth=AUTH

specify the auth password for target

  • -e, --extra

dump or restore following redis backlog commands

  • --redis

target is normal redis instance, default value is false.

  • --codis

target is codis proxy, default value is true.

  • --filterdb=DB

filter specifed db number, default value is '*'

Examples

  • DECODE
$ cat dump.rdb | ./redis-port decode 2>/dev/null
 {"db":0,"type":"string","key":"a","value":"hello"}
 {"db":1,"type":"string","key":"a","value":"9"}
 {"db":0,"type":"hash","key":"c","field":"hello","value":"world"}
 {"db":0,"type":"expire","key":"c","expireat":1487663341422}
 {"db":0,"type":"list","key":"b","index":0,"value":"hello"}
 {"db":0,"type":"list","key":"b","index":1,"value":"world"}
 {"db":0,"type":"zset","key":"d","member":"hello","score":1}
 {"db":0,"type":"zset","key":"d","member":"world","score":1.8}
  ... ...
  • RESTORE
$ ./redis-port restore -i dump.rdb -t 127.0.0.1:6379 -n 8
  2014/10/28 15:08:26 [ncpu=8] restore from 'dump.rdb' to '127.0.0.1:6379'
  2014/10/28 15:08:27 total = 280149161 -     14267777 [  5%]
  2014/10/28 15:08:28 total = 280149161 -     27325530 [  9%]
  2014/10/28 15:08:29 total = 280149161 -     40670677 [ 14%]
  ... ...                                                    
  2014/10/28 15:08:47 total = 280149161 -    278070563 [ 99%]
  2014/10/28 15:08:47 total = 280149161 -    280149161 [100%]
  2014/10/28 15:08:47 done
  • DUMP
$ ./redis-port dump -f 127.0.0.1:6379 -o save.rdb
  2014/10/28 15:12:05 [ncpu=1] dump from '127.0.0.1:6379' to 'save.rdb'
  2014/10/28 15:12:06 -
  2014/10/28 15:12:07 -
  ... ...
  2014/10/28 15:12:10 total = 278110192 -            0 [  0%]
  2014/10/28 15:12:11 total = 278110192 -    278110192 [100%]
  2014/10/28 15:12:11 done

$ ./redis-port dump -f 127.0.0.1:6379 | tee save.rdb | ./redis-port decode -o save.log -n 8 2>/dev/null
  2014/10/28 15:12:55 [ncpu=1] dump from '127.0.0.1:6379' to '/dev/stdout'
  2014/10/28 15:12:56 -
  ... ...
  2014/10/28 15:13:10 total = 278110192  -   264373070 [  0%]
  2014/10/28 15:13:11 total = 278110192  -   278110192 [100%]
  2014/10/28 15:13:11 done
  • SYNC
$ ./redis-port sync -f 127.0.0.1:6379 -t 127.0.0.1:6380 -n 8
  2014/10/28 15:15:41 [ncpu=8] sync from '127.0.0.1:6379' to '127.0.0.1:6380'
  2014/10/28 15:15:42 -
  2014/10/28 15:15:43 -
  2014/10/28 15:15:44 -
  2014/10/28 15:15:46 total = 278110192 -      9380927 [  3%]
  2014/10/28 15:15:47 total = 278110192 -     18605075 [  6%]
  ... ...                                              [    ]
  2014/10/28 15:16:14 total = 278110192 -    269990892 [ 97%]
  2014/10/28 15:16:15 total = 278110192 -    278110192 [100%]
  2014/10/28 15:16:15 done
  2014/10/28 15:16:17 pipe: send = 0             recv = 0
  2014/10/28 15:16:18 pipe: send = 0             recv = 0
  ... ...

Extension points exported contracts — how you extend this code

Closer (Interface)
(no doc) [2 implementers]
pkg/libs/io/pipe/pipeio.go
Resp (Interface)
(no doc)
pkg/redis/resp.go
Reader (Interface)
(no doc) [2 implementers]
pkg/libs/io/pipe/pipeio.go
HandlerFunc (FuncType)
(no doc)
pkg/redis/handler.go
Writer (Interface)
(no doc) [2 implementers]
pkg/libs/io/pipe/pipeio.go

Core symbols most depended-on inside this repo

Close
called by 40
pkg/libs/io/pipe/pipeio.go
Write
called by 15
pkg/libs/io/pipe/pipe.go
String
called by 12
pkg/redis/resp.go
DecodeDump
called by 9
pkg/rdb/decoder.go
readString
called by 9
pkg/rdb/reader.go
readLength
called by 9
pkg/rdb/reader.go
New
called by 7
pkg/libs/io/pipe/pipe.go
Write
called by 7
pkg/rdb/digest/crc64.go

Shape

Method 149
Function 133
Struct 36
TypeAlias 7
Interface 6
FuncType 1

Languages

Go100%

Modules by API surface

pkg/rdb/decoder.go29 symbols
pkg/redis/resp.go24 symbols
pkg/rdb/reader.go23 symbols
pkg/libs/io/pipe/pipe.go23 symbols
pkg/rdb/encoder.go19 symbols
pkg/libs/io/pipe/pipe_test.go19 symbols
cmd/utils.go17 symbols
pkg/rdb/encoder_test.go16 symbols
pkg/libs/io/pipe/pipeio.go16 symbols
pkg/redis/encoder.go14 symbols
pkg/redis/decoder.go12 symbols
pkg/rdb/loader_test.go10 symbols

For agents

$ claude mcp add redis-port \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact