We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Example Code:
func TestRdbEncDec(t *testing.T) { // encoding buf := bytes.NewBuffer(make([]byte, 0, 1024*1024*1024)) enc := encoder.NewEncoder(buf) err := enc.WriteHeader() require.Nil(t, err) auxMap := map[string]string{ "redis-ver": "5.0.9", "redis-bits": "64", "aof-preamble": "0", } for k, v := range auxMap { err = enc.WriteAux(k, v) require.Nil(t, err) } err = enc.WriteDBHeader(0, 1, 1) require.Nil(t, err) expirationMs := uint64(time.Now().Add(time.Hour*8).Unix() * 1000) err = enc.WriteHashMapObject("hash", map[string][]byte{ "001": []byte("007"), }, encoder.WithTTL(expirationMs)) require.Nil(t, err) err = enc.WriteEnd() require.Nil(t, err) // decoding decoder := parser.NewDecoder(buf) err = decoder.Parse(func(o parser.RedisObject) bool { switch o.GetType() { case parser.StringType: str := o.(*parser.StringObject) println(str.Key, str.Value) case parser.ListType: list := o.(*parser.ListObject) println(list.Key, list.Values) case parser.HashType: hash := o.(*parser.HashObject) mp := make(map[string]string, len(hash.Hash)) for k, v := range hash.Hash { mp[k] = string(v) } fmt.Printf("HASH: key=%s, hash=%+v\n", hash.Key, mp) case parser.ZSetType: zset := o.(*parser.ZSetObject) println(zset.Key, zset.Entries) case parser.SetType: set := o.(*parser.SetObject) println(set.Key, set.Members) } // return true to continue, return false to stop the iteration return true }) require.Nil(t, err) }
it prints
=== RUN TestRdbEncDec HASH: key=hash, hash=map[1:7]
the problem is encoding of number like strings is wrong, for instance, the encoder will treat "001" as "1".
I think the problem is originated from this line of code:
rdb/core/string.go
Line 218 in 9a02a4e
Edit: I came up with a PR #39
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Example Code:
it prints
the problem is encoding of number like strings is wrong, for instance, the encoder will treat "001" as "1".
I think the problem is originated from this line of code:
rdb/core/string.go
Line 218 in 9a02a4e
where strconv.ParseInt() is miss-used.
Edit: I came up with a PR #39
The text was updated successfully, but these errors were encountered: