Skip to main content
The Deno 2 Release Candidate is here
Learn more
Module

x/tpy/src/kv.ts>TpyKV#cas

🔑 A strongly typed Pylon API client.
Latest
method TpyKV.prototype.cas
import { TpyKV } from "https://deno.land/x/tpy@v1.0.0-RC/src/kv.ts";

Compare and set a key's value.

Parameters

key: string

The key to compare and set.

compare: Json

The object to compare with the key's value.

set: Json

The value the key will be set to if compare matches the key's value.

optional
ttl: Date | number

Optional ttl, either a number, which is the ttl in milliseconds, or a Date when the key should expire.

Returns

Promise<void>

Compare and set a key's value, setting the value only if the key does not already exist.

Parameters

key: string

The key to compare and set.

compare: undefined

The object to compare with the key's value.

set: Json

The value the key will be set to if the key does not exist.

optional
ttl: Date | number

Optional ttl, either a number, which is the ttl in milliseconds, or a Date when the key should expire.

Returns

Promise<void>

Compare and delete a key's value. This is functionally equivalent to delete, if the prevValue option is provided.

Parameters

key: string

The key to compare and set.

compare: Json

The object to compare with the key's value.

set: undefined

Optional ttl, either a number, which is the ttl in milliseconds, or a Date when the key should expire.

optional
ttl: Date | number

Returns

Promise<void>