Skip to main content
Module

x/tpy/mod.ts>TpyKV

🔑 A strongly typed Pylon API client.
Go to Latest
class TpyKV
import { TpyKV } from "https://deno.land/x/tpy@v1.0.0-pre-release-9/mod.ts";

A KVNamespace interface that (almost) matches the Pylon KVNamespace SDK class.

Constructors

new
TpyKV(
tpyInstance: Tpy,
deploymentID: StringifiedNumber,
kvnamespace: string,
)

Properties

private
deploymentID: StringifiedNumber
private
tpyc: Tpy
readonly
kvnamespace: string

The KV namespace title.

Methods

Clears the namespace. Returning the number of keys deleted.

This operation will delete all the data in the namespace. The data is irrecoverably deleted.

Use with caution!

Returns the number of keys present in this namespace.

delete(key: string, options?: KV.OperationOptions.Delete)

Deletes a given key from the namespace. Throwing if the key does not exist, or if options.prevValue is set the previous value is not equal to the value provided.

get<T extends Json = Json>(key: string): Promise<T | undefined>

Gets a key's value - returning the value or undefined.

getArrayBuffer(key: string): Promise<ArrayBuffer | undefined>

Gets a key's value - returning the value or undefined.

items<T>(options?: KV.OperationOptions.Items): Promise<KV.GET.ItemsFlattened<T>>

Lists the keys and values in a namespace, including their expiration date if applicable.

The maximum limit is 100, however.

list(options?: KV.OperationOptions.List)

Lists the keys that are set within the namespace.

put(
key: string,
value: Json,
options?: KV.OperationOptions.Put,
)

Sets the value of a given key within the key-value store.

putArrayBuffer(
key: string,
value: ArrayBuffer,
options?: KV.OperationOptions.Put,
)

Sets the value of a given key within the key-value store.