Skip to main content
method Deno.Kv.prototype.enqueue

Add a value into the database queue to be delivered to the queue listener via Deno.Kv.listenQueue.

const db = await Deno.openKv();
await db.enqueue("bar");

The delay option can be used to specify the delay (in milliseconds) of the value delivery. The default delay is 0, which means immediate delivery.

const db = await Deno.openKv();
await db.enqueue("bar", { delay: 60000 });

The keysIfUndelivered option can be used to specify the keys to be set if the value is not successfully delivered to the queue listener after several attempts. The values are set to the value of the queued message.

The backoffSchedule option can be used to specify the retry policy for failed message delivery. Each element in the array represents the number of milliseconds to wait before retrying the delivery. For example, [1000, 5000, 10000] means that a failed delivery will be retried at most 3 times, with 1 second, 5 seconds, and 10 seconds delay between each retry.

const db = await Deno.openKv();
await db.enqueue("bar", {
  keysIfUndelivered: [["foo", "bar"]],
  backoffSchedule: [1000, 5000, 10000],
});

Parameters

value: unknown
optional
options: { delay?: number; keysIfUndelivered?: Deno.KvKey[]; backoffSchedule?: number[]; }