redis: skip marshalling if []byte (#23)

This commit is contained in:
Yaron Schneider 2019-10-06 07:53:26 -07:00 committed by GitHub
parent 2b8dbd2b44
commit 70c06fadd8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 2 deletions

View File

@ -192,9 +192,15 @@ func (r *StateStore) setValue(req *state.SetRequest) error {
ver = 0
}
b, _ := r.json.Marshal(req.Value)
bt := []byte{}
b, ok := req.Value.([]byte)
if ok {
bt = b
} else {
bt, _ = r.json.Marshal(req.Value)
}
res := r.client.Do(context.Background(), "EVAL", setQuery, 1, req.Key, ver, b)
res := r.client.Do(context.Background(), "EVAL", setQuery, 1, req.Key, ver, bt)
if err := redis.AsError(res); err != nil {
return fmt.Errorf("failed to set key %s: %s", req.Key, err)
}