redis: skip marshalling if []byte (#23)
This commit is contained in:
parent
2b8dbd2b44
commit
70c06fadd8
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue