Cloudflare 中文文档
Durable Objects
编辑这个页面
跳转官方原文档
Set theme to dark (⇧+D)

Use KV from Durable Objects

Read and write to/from KV within a Durable Object

The following Worker script shows you how to configure a Durable Object to read from and/or write to a Workers KV namespace. This is useful when using a Durable Object to coordinate between multiple clients, and allows you to serialize writes to KV and/or broadcast a single read from KV to hundreds or thousands of clients connected to a single Durable Object using WebSockets.

Prerequisites:

Configure your wrangler.toml file as follows: