import { Pipeline } from "https://deno.land/x/upstash_redis@v1.23.4/pkg/pipeline.ts";
Upstash REST API supports command pipelining to send multiple commands in batch, instead of sending each command one by one and waiting for a response. When using pipelines, several commands are sent using a single HTTP request, and a single JSON array response is returned. Each item in the response array corresponds to the command in the same order within the pipeline.
NOTE:
Execution of the pipeline is not atomic. Even though each command in the pipeline will be executed in order, commands sent by other clients can interleave with the pipeline.
Examples:
const p = redis.pipeline() // or redis.multi()
p.set("key","value")
p.get("key")
const res = await p.exec()
You can also chain commands together
const p = redis.pipeline()
const res = await p.set("key","value").get("key").exec()
Return types are inferred if all commands are chained, but you can still override the response type manually:
redis.pipeline()
.set("key", { greeting: "hello"})
.get("key")
.exec<["OK", { greeting: string } ]>()
Constructors
Type Parameters
Properties
Send the pipeline request to upstash.
Returns an array with the results of all pipelined commands.
If all commands are statically chained from start to finish, types are inferred. You can still define a return type manually if necessary though:
const p = redis.pipeline()
p.get("key")
const result = p.exec<[{ greeting: string }]>()