From d7e515adb2ec5a70dba715463c8407bfd1cd8966 Mon Sep 17 00:00:00 2001 From: vinllen Date: Tue, 25 Jun 2019 22:28:27 +0800 Subject: [PATCH] support lua in decode mode --- src/redis-shake/decode.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/redis-shake/decode.go b/src/redis-shake/decode.go index 880a9d5..986f731 100644 --- a/src/redis-shake/decode.go +++ b/src/redis-shake/decode.go @@ -136,11 +136,25 @@ func (cmd *CmdDecode) decoderMain(ipipe <-chan *rdb.BinEntry, opipe chan<- strin return string(b) } for e := range ipipe { + var b bytes.Buffer + if e.Type == rdb.RdbFlagAUX && string(e.Key) == "lua" { + o := &struct { + Type string `json:"type"` + Key string `json:"key"` + Value64 string `json:"value64"` + }{ + "aux", "lua", string(e.Value), + } + fmt.Fprintf(&b, "%s\n", toJson(o)) + cmd.nentry.Incr() + opipe <- b.String() + continue + } + o, err := rdb.DecodeDump(e.Value) if err != nil { log.PanicError(err, "decode failed") } - var b bytes.Buffer switch obj := o.(type) { default: log.Panicf("unknown object %v", o)