Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/natsws/src/mod.ts>KV

WebSocket NATS
Go to Latest
interface KV
implements RoKV
import { type KV } from "https://deno.land/x/natsws@v1.28.0/src/mod.ts";

Methods

create(k: string, data: Payload): Promise<number>

Creates a new entry ensuring that the entry does not exist (or the current version is deleted or the key is purged) If the entry already exists, this operation fails.

update(
k: string,
data: Payload,
version: number,
): Promise<number>

Updates the existing entry provided that the previous sequence for the Kv is at the specified version. This ensures that the KV has not been modified prior to the update.

put(
k: string,
data: Payload,
opts?: Partial<KvPutOptions>,
): Promise<number>

Sets or updates the value stored under the specified key.

delete(k: string, opts?: Partial<KvDeleteOptions>): Promise<void>

Deletes the entry stored under the specified key. Deletes are soft-deletes. The server will add a new entry marked by a "DEL" operation. Note that if the KV was created with an underlying limit (such as a TTL on keys) it is possible for a key or the soft delete marker to be removed without additional notification on a watch.

purge(k: string, opts?: Partial<KvDeleteOptions>): Promise<void>

Deletes and purges the specified key and any value history.

destroy(): Promise<boolean>

Destroys the underlying stream used by the KV. This effectively deletes all data stored under the KV.