Skip to main content
Module

x/cloudflare_kv_storage/index.ts>CloudflareStorageArea

An implementation of the StorageArea interface using Cloudflare Worker's KV storage as a backing store
Go to Latest
class CloudflareStorageArea
implements StorageArea
import { CloudflareStorageArea } from "https://deno.land/x/cloudflare_kv_storage@v0.9.0-pre.4/index.ts";

An implementation of the StorageArea interface wrapping Cloudflare Worker's KV store.

The goal of this class is ease of use and compatibility with other Storage Area implementations, such as https://github.com/GoogleChromeLabs/kv-storage-polyfill.

While work on the specification itself has stopped, it's still a good interface for asynchronous data access that feels native to JavaScript.

Note that efficiency is not a goal. Specifically, if you have sizable ArrayBuffers, it's much better to use Cloudflare's KV directly.

Constructors

new
CloudflareStorageArea(name?: string, opts?: KVOptions)
new
CloudflareStorageArea(name?: KVNamespace, opts?: Omit<KVOptions, "namespace">)
new
CloudflareStorageArea(name?: string | KVNamespace, options?: KVOptions)

Methods

entries<T>(opts?: KVListOptions): AsyncGenerator<[Key, T]>
get<T>(key: AllowedKey, opts?: unknown): Promise<T>
keys(opts?: KVListOptions): AsyncGenerator<Key>
set<T>(
value: T | undefined,
opts?: KVPutOptions,
): Promise<void>
values<T>(opts?: KVListOptions): AsyncGenerator<T>

Static Properties

optional
defaultKVNamespace: KVNamespace