File tree Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -169,6 +169,26 @@ extension ValkeyClient: ValkeyConnectionProtocol {
169
169
}
170
170
}
171
171
172
+ extension ValkeyClient {
173
+ /// Pipeline a series of commands to Valkey connection
174
+ ///
175
+ /// This function will only return once it has the results of all the commands sent
176
+ /// - Parameter commands: Parameter pack of ValkeyCommands
177
+ /// - Returns: Parameter pack holding the results of all the commands
178
+ @inlinable
179
+ public func pipeline< each Command : ValkeyCommand > (
180
+ _ commands: repeat each Command
181
+ ) async -> sending ( repeat Result < ( each Command ) . Response, Error > ) {
182
+ do {
183
+ return try await self . withConnection { connection in
184
+ await connection. pipeline ( repeat ( each commands) )
185
+ }
186
+ } catch {
187
+ return ( repeat Result< ( each Command) . Response, Error> . failure( error) )
188
+ }
189
+ }
190
+ }
191
+
172
192
#if ServiceLifecycleSupport
173
193
extension ValkeyClient : Service { }
174
194
#endif // ServiceLifecycle
Original file line number Diff line number Diff line change @@ -165,6 +165,21 @@ struct GeneratedCommands {
165
165
}
166
166
}
167
167
168
+ @Test
169
+ func testPipelinedSetGetClient( ) async throws {
170
+ var logger = Logger ( label: " Valkey " )
171
+ logger. logLevel = . debug
172
+ try await withValkeyClient ( . hostname( valkeyHostname, port: 6379 ) , logger: logger) { client in
173
+ try await withKey ( connection: client) { key in
174
+ let responses = await client. pipeline (
175
+ SET ( key: key, value: " Pipelined Hello " ) ,
176
+ GET ( key: key)
177
+ )
178
+ try #expect( responses. 1 . get ( ) ? . decode ( as: String . self) == " Pipelined Hello " )
179
+ }
180
+ }
181
+ }
182
+
168
183
@Test
169
184
func testTransactionSetIncrGet( ) async throws {
170
185
var logger = Logger ( label: " Valkey " )
You can’t perform that action at this time.
0 commit comments