go-redis
go-redis copied to clipboard
Client.Pipelined().TxPipeline() is not a transaction?
Hi! Just getting familiar with the library and I'm looking to do the following:
var c *redis.Client = ...
_, err := c.Pipelined(ctx, func(p redis.Pipeliner) error {
// Do stuff with p
// ....
// Inner transactions
for ... {
_, er r:= p.TxPipelined(ctx, func(pTx redis.Pipeliner) error {
// Do stuff with pTx
}
}
// Do more stuff with p
// ....
return err
}
https://github.com/go-redis/redis/blob/143859e34596a8e80ee858b5842d503d86572249/pipeline.go#L118-L137
The code above does not seem to wrap the nested pipeline into a transaction, is that right? Is that a bug?
Hm, I guess what I want is to have a pipeline of many transactions. Can I do that?
@ash2k no, having multiple transactions in a pipeline is not supported.
To achieve that you can use Lua script: https://redis.io/commands/eval to execute multiple operations in single transaction. Since it's treated as single command then you can surround that with pipeline to send multiple commands at once.
This issue is marked stale. It will be closed in 30 days if it is not updated.