digitalwerber

payload kv cloudflare

by digitalwerber
Databases & data
v3
v4
^3.62.0 || ^4.0.0-beta.7
MIT

Overview

Summary generated from the README

Provides a Cloudflare Workers KV backed adapter for Payload's kv config option, so data written through payload.kv lands in a KV namespace binding. Supports per-prefix expiration and a configurable key prefix so the namespace can be shared. Requires Payload 3.62 or later, or Payload 4 beta, and a Worker KV binding.

Features

  • Implements Payload's kv adapter on top of a Workers KV namespace binding
  • Per-key-prefix TTL in seconds, longest matching prefix wins
  • Configurable key prefix so keys() and clear() only touch Payload's keys
  • Shortens keys over 512 bytes with a hash while keys() returns the full key
  • Pages through the full list for keys() and clear()

Use cases

  • Cache query results from payload.kv in a Payload app deployed on Cloudflare Workers
  • Store expiring key-value data in a KV namespace that also holds other application data

From the author

Payload KV adapter for Cloudflare Workers KV

Installation

npm i @digitalwerber/payload-kv-cloudflare

0

Stars

0

Forks

0

Open Issues

1 months ago

Last Updated

63

Weekly Downloads

v0.1.0

npm Version

21.1 KB

Unpacked Size

0

Dependencies

GitHub stars

00 since Nov 1

Show data
GitHub stars by day (UTC)
DateStars
Dec 6, 20260
Dec 5, 20260
Dec 4, 20260
Dec 3, 20260
Dec 2, 20260
Dec 1, 20260
Nov 30, 20260
Nov 29, 20260
Nov 28, 20260
Nov 27, 20260
Nov 26, 20260
Nov 25, 20260
Nov 24, 20260
Nov 23, 20260
Nov 22, 20260
Nov 21, 20260
Nov 20, 20260
Nov 19, 20260
Nov 18, 20260
Nov 17, 20260
Nov 16, 20260
Nov 15, 20260
Nov 14, 20260
Nov 13, 20260
Nov 12, 20260
Nov 11, 20260
Nov 10, 20260
Nov 9, 20260
Nov 8, 20260
Nov 7, 20260
Nov 6, 20260
Nov 5, 20260
Nov 4, 20260
Nov 3, 20260
Nov 2, 20260
Nov 1, 20260
npm weekly downloads

56+56 since Nov 5

Show data
npm weekly downloads by day (UTC)
DateWeekly downloads
Dec 6, 202656
Dec 5, 202657
Dec 4, 2026128
Dec 3, 202691
Dec 2, 202696
Dec 1, 2026155
Nov 30, 2026156
Nov 29, 2026156
Nov 28, 2026163
Nov 27, 202699
Nov 26, 2026163
Nov 25, 2026173
Nov 24, 2026138
Nov 23, 2026171
Nov 22, 2026216
Nov 21, 2026240
Nov 20, 2026248
Nov 19, 2026185
Nov 18, 2026210
Nov 17, 2026213
Nov 16, 2026211
Nov 15, 2026177
Nov 14, 2026200
Nov 13, 2026578
Nov 12, 2026571
Nov 11, 2026529
Nov 10, 2026498
Nov 9, 2026466
Nov 8, 2026452
Nov 7, 2026393
Nov 6, 20260
Nov 5, 20260

Each point is npm's rolling 7-day download count.

Health Score

66/100Good

Composite score based on GitHub activity, stars, npm downloads, publish recency, dependency count, and package size.

Badge for your README

Payload Directory health badge
Markdown
[![Payload Directory](https://payloaddirectory.dev/badge/1446091336-root.svg)](https://payloaddirectory.dev/plugins/1446091336-root)
HTML
<a href="https://payloaddirectory.dev/plugins/1446091336-root"><img src="https://payloaddirectory.dev/badge/1446091336-root.svg" alt="Payload Directory"></a>
Updated Nov 5, 2026Created Nov 4, 2026Published Nov 4, 2026

README

@digitalwerber/payload-kv-cloudflare

A Payload KV adapter backed by Cloudflare Workers KV. Use it as kv in your Payload config, then read and write through payload.kv.

Install

pnpm add @digitalwerber/payload-kv-cloudflare

Usage

Pass the KV namespace binding of your Worker:

import { cloudflareKVAdapter } from '@digitalwerber/payload-kv-cloudflare'
import { buildConfig } from 'payload'

export default buildConfig({
  // ...
  kv: cloudflareKVAdapter({
    namespace: env.KV,
    ttl: { 'cache:': 30 * 24 * 3600 },
  }),
})
await payload.kv.set('cache:posts', posts) // expires after 30 days
await payload.kv.get('cache:posts')

Options

OptionDefaultDescription
namespacerequiredThe Workers KV binding (KVNamespace).
ttl{}Expiration in seconds per key prefix. The longest matching prefix wins; keys without a match never expire. Values under 60 are raised to 60.
keyPrefix'payload-kv:'Prefix for the stored keys. keys() and clear() only see keys with this prefix, so the namespace can hold other data.

Supported Payload versions

Payload 3.62 and later, Payload 4 (beta).

Limits

Handled by the adapter

  • Keys over 512 bytes are stored under a shortened key: its start, including the prefix, followed by a hash of the full key. ttl still applies and keys() returns the full key. Keys of about 1000 bytes and more are rejected, because the full key has to fit into the 1024 bytes of KV metadata.
  • Expiration is at least 60 seconds.
  • keys() and clear() page through the whole list.

Not handled by the adapter

For the current numbers, see Cloudflare's KV limits.

  • Eventual consistency. A write reaches other locations with a delay. Don't use the store for values several requests must agree on at once, such as counters or locks.
  • Writes to the same key are rate limited; more frequent writes may fail.
  • KV operations per Worker invocation are limited. clear() deletes key by key, so on a larger store it can fail part way; call it again in a new invocation until keys() is empty.
  • Values are stored as JSON and count against the KV value size limit.

License

MIT

Similar plugins