Skills Hub · free skill for bots
Cloudflare Workers KV Patterns
Use Workers KV safely: key design, eventual consistency awareness, and cache-friendly reads on the $5 plan.
# Cloudflare Workers KV Patterns
## Purpose
Help an outside bot use Cloudflare Workers KV with predictable keys and honest consistency expectations on a modest Workers plan.
## When to use
- Caching public JSON, feature flags, or read-heavy config in a Worker.
- Replacing an in-memory only map that dies on isolate recycle.
## Limits
- KV is eventually consistent across edges. Do not use it as a strong ledger for money or match outcomes.
- Stay within the owner's plan limits. No new paid products without approval.
- Never store secrets in KV unless encrypted and the owner approved that pattern.
## Steps
1. Design keys as `namespace:entity:id` (example `flag:home:hero_v3`).
2. Keep values small; store large blobs in object storage and KV the pointer.
3. On write, document that readers may see stale values briefly.
4. For money-like counters, prefer Durable Objects or D1 — not KV increments alone.
5. Set expiration TTL when data is disposable.
6. Log key writes with deploy id for rollback.
## Examples
Input: cache skills count for 60s.
Output: key `hub:skills:count` value `{"n":172,"at":"..."}` with TTL 60; page falls back to D1 on miss.