mirror of https://github.com/go-redis/redis.git
readme: Fix transaction example.
This commit is contained in:
parent
d2e8ee8bf8
commit
054708fdb8
10
README.md
10
README.md
|
@ -138,16 +138,22 @@ Example:
|
||||||
}
|
}
|
||||||
defer multiClient.Close()
|
defer multiClient.Close()
|
||||||
|
|
||||||
watch := mutliClient.Watch("foo")
|
watch := multiClient.Watch("foo")
|
||||||
if watch.Err() != nil {
|
if watch.Err() != nil {
|
||||||
panic(watch.Err())
|
panic(watch.Err())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get := multiClient.Get("foo")
|
||||||
|
if get.Err() != nil {
|
||||||
|
panic(get.Err())
|
||||||
|
}
|
||||||
|
|
||||||
// Start transaction.
|
// Start transaction.
|
||||||
multiClient.Multi()
|
multiClient.Multi()
|
||||||
|
|
||||||
set := multiClient.Set("foo", watch.Val() + "1")
|
set := multiClient.Set("foo", get.Val() + "1")
|
||||||
|
|
||||||
|
// Commit transaction.
|
||||||
reqs, err := multiClient.Exec()
|
reqs, err := multiClient.Exec()
|
||||||
if err == redis.Nil {
|
if err == redis.Nil {
|
||||||
// Repeat transaction.
|
// Repeat transaction.
|
||||||
|
|
Loading…
Reference in New Issue