Store key-value data globally with Cloudflare KV's edge network. Use when: caching API responses, storing configuration, managing user preferences, handling TTL expiration, or troubleshooting KV_ERROR, 429 rate limits, eventual consistency, or cacheTtl errors.
Complete knowledge domain for Cloudflare Workers KV - global, low-latency key-value storage on Cloudflare's edge network.
This skill provides complete Workers KV knowledge including:
| Issue | Description | Prevention | |-------|-------------|------------| | 1 write/sec limit | Concurrent writes to same key cause 429 errors | Document rate limits + retry logic with backoff | | Eventually consistent | Writes take up to 60s to propagate globally | Set expectations, use cacheTtl appropriately | | cacheTtl minimum 60s | Setting lower than 60s fails | Always use 60+ seconds for cacheTtl | | Metadata 1024 byte limit | Exceeding metadata size causes errors | Validate metadata size before put() | | Value 25MB limit | Large values fail to store | Check size before writing | | 1000 operations/invocation | Exceeding causes Worker failure | Use bulk operations, batch reads |
import { Hono } from 'hono';
type Bindings = {
CONFIG: KVNamespace;
};
const app = new Hono<{ Bindings: Bindings }>();
// Write with expiration
app.post('/config/:key', async (c) => {
const key = c.req.param('key');
const value = await c.req.text();
await c.env.CONFIG.put(key, value, {
expirationTtl: 3600, // Expire in 1 hour
metadata: { updatedAt: Date.now(), updatedBy: 'admin' },
});
return c.json({ success: true, key });
});
// Read with cache optimization
app.get('/config/:key', async (c) => {
const key = c.req.param('key');
const { value, metadata } = await c.env.CONFIG.getWithMetadata(key, {
type: 'json',
cacheTtl: 300, // Cache for 5 minutes at edge
});
if (!value) {
return c.json({ error: 'Not found' }, 404);
}
return c.json({ value, metadata });
});
// List with prefix and pagination
app.get('/config/list/:prefix?', async (c) => {
const prefix = c.req.param('prefix') || '';
const cursor = c.req.query('cursor');
const result = await c.env.CONFIG.list({
prefix,
limit: 100,
cursor: cursor || undefined,
});
return c.json({
keys: result.keys,
hasMore: !result.list_complete,
cursor: result.cursor,
});
});
export default app;
SKILL.md - Complete KV knowledge domaintemplates/wrangler-kv-config.jsonc - KV namespace bindingstemplates/kv-basic-operations.ts - CRUD operations Workertemplates/kv-caching-pattern.ts - Cache optimization patternstemplates/kv-list-pagination.ts - List with cursor paginationtemplates/kv-metadata-pattern.ts - Metadata usage patternsreference/workers-api.md - Complete Workers API referencereference/best-practices.md - Performance & caching strategies✅ Production Ready
This skill is based on:
Last Updated: 2025-10-21 Status: Production Ready ✅ Maintainer: Jeremy Dawes | jeremy@jezweb.net
npx skills add ovachiever/Cloudflare KV(键值存储)下载完整 Skill 目录,包含 SKILL.md 及所有相关文件
Search for places (restaurants, cafes, etc.) via Google Places API proxy on localhost.
Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Start voice calls via the OpenClaw voice-call plugin.
Notion API for creating and managing pages, databases, and blocks.
Gemini CLI for one-shot Q&A, summaries, and generation.
Category:developer