@@ -146,7 +146,7 @@ extension ValkeyNodeClient {
146
146
/// - Parameter commands: Parameter pack of ValkeyCommands
147
147
/// - Returns: Parameter pack holding the results of all the commands
148
148
@inlinable
149
- public func execute< each Command : ValkeyCommand > (
149
+ func execute< each Command : ValkeyCommand > (
150
150
_ commands: repeat each Command
151
151
) async -> sending ( repeat Result < ( each Command ) . Response, Error > ) {
152
152
do {
@@ -171,7 +171,7 @@ extension ValkeyNodeClient {
171
171
/// - Parameter commands: Collection of ValkeyCommands
172
172
/// - Returns: Array holding the RESPToken responses of all the commands
173
173
@inlinable
174
- public func execute< Commands: Collection & Sendable > (
174
+ func execute< Commands: Collection & Sendable > (
175
175
_ commands: Commands
176
176
) async -> sending [ Result < RESPToken , Error > ] where Commands. Element == any ValkeyCommand {
177
177
do {
@@ -183,6 +183,49 @@ extension ValkeyNodeClient {
183
183
}
184
184
}
185
185
186
+ /// Pipeline a series of commands as a transaction to Valkey connection
187
+ ///
188
+ /// Another client will never be served in the middle of the execution of these
189
+ /// commands. See https://valkey.io/topics/transactions/ for more information.
190
+ ///
191
+ /// Once all the responses for the commands have been received the function returns
192
+ /// a parameter pack of Results, one for each command.
193
+ ///
194
+ /// - Parameter commands: Parameter pack of ValkeyCommands
195
+ /// - Returns: Parameter pack holding the responses of all the commands
196
+ @inlinable
197
+ func transaction< each Command : ValkeyCommand > (
198
+ _ commands: repeat each Command
199
+ ) async throws -> sending ( repeat Result < ( each Command ) . Response, Error > ) {
200
+ try await self . withConnection { connection in
201
+ try await connection. transaction ( repeat ( each commands) )
202
+ }
203
+ }
204
+
205
+ /// Pipeline a series of commands as a transaction to Valkey connection
206
+ ///
207
+ /// Another client will never be served in the middle of the execution of these
208
+ /// commands. See https://valkey.io/topics/transactions/ for more information.
209
+ ///
210
+ /// Once all the responses for the commands have been received the function returns
211
+ /// an array of RESPToken Results, one for each command.
212
+ ///
213
+ /// This is an alternative version of the pipelining function ``ValkeyNodeClient/transaction(_:)->(_,_)``
214
+ /// that allows for a collection of ValkeyCommands. It provides more flexibility but is
215
+ /// slightly more expensive to run and the command responses are returned as ``RESPToken``
216
+ /// instead of the response type for the command.
217
+ ///
218
+ /// - Parameter commands: Collection of ValkeyCommands
219
+ /// - Returns: Array holding the RESPToken responses of all the commands
220
+ @inlinable
221
+ func transaction< Commands: Collection & Sendable > (
222
+ _ commands: Commands
223
+ ) async throws -> sending [ Result < RESPToken , Error > ] where Commands. Element == any ValkeyCommand {
224
+ try await self . withConnection { connection in
225
+ try await connection. transaction ( commands)
226
+ }
227
+ }
228
+
186
229
/// Internal command used by cluster client, that precedes each command with a ASKING
187
230
/// command
188
231
func executeWithAsk< Commands: Collection & Sendable > (
0 commit comments