简体   繁体   中英

should I check error each step on a redis multi transaction?

should I check error each step on a redis multi transaction? if some error happen, was it mean, the release command will also return error?

eg. can I :

 conn.Do("multi")
 conn.Do("set", "mm", "xx")
 reply, err := conn.Do("exec")
 if err != nil {
      ....
  }

or, should i :

  _, err := conn.Do("multi")
 if err != nil {
     ....
     return
 }
_, err := conn.Do("set", "mm", "xx")
if err != nil {
     ....
    return
 }
 reply, err := conn.Do("exec")
if err != nil {
    ....
   return
 }

To transact, you need to Send() each command, and only Do() the EXEC. Error checking should be done for the Do() only, like so:

conn.Send("MULTI")
conn.Send("SET", "foo", "bar")
...
reply, err := conn.Do("EXEC")
if err != nil {
    ...
}
...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM