I have a scenario similar to the following :
txf := func(tx *redis.Tx) error {
// Phase 1:
// read some stuff by several get/hget request which I want to send with pipeline
// to avoid unnecessarily rounds to the redis server
// Phase 2: Prepare new data based on read data
// Phase 3: Write the new data with a transaction to use the watch protection if original keys changed
_, err = tx.Pipelined(func(pipe redis.Pipeliner) error {
// pipe handles the error case
pipe.Set(key, value, 0)
return nil})
return err
}
err := client.Watch(txf, key)
From reading the library code it seems that tx.TxPipeline and tx.Pipeline both returns in this case a multi/exec implementation which means that if I'll use it for reading data (phase 1) I'll lose the watch protection in the second pipeline I use to update the data.
Any solutions will be appriciated.