cf-workers-memkv
TypeScript icon, indicating that this package has built-in type declarations

2.0.0 • Public • Published

cf-workers-memkv

Build Status dependencies Status

In memory Cloudflare workers KV store for testing.

Install

npm install cf-workers-memkv

Usage

import { MemKV } from 'cf-workers-memkv'

const fruits = new MemKV()

const key = 'apple:grannysmith'
const value = { name: 'Granny Smith', type: 'apple', color: 'green' }
const metadata = { name: 'Granny Smith' }

await fruits.put(key, JSON.stringify(value), { metadata })

const apple = await fruits.get(key, 'json')
console.log(apple) // { name: 'Granny Smith', type: 'apple', color: 'green' }

const apples = await fruits.list({ prefix: 'apple:' })
console.log(apples) // { keys: [{ name: 'apple:grannysmith', metadata: { name: 'Granny Smith' } }], list_complete: true }

await fruits.delete(key)

API

See Cloudflare Workers Runtime API docs.

Contribute

Feel free to dive in! Open an issue or submit PRs.

License

MIT © Alan Shaw

Readme

Keywords

Package Sidebar

Install

npm i cf-workers-memkv

Weekly Downloads

1

Version

2.0.0

License

MIT

Unpacked Size

3.97 kB

Total Files

6

Last publish

Collaborators

  • alanshaw