Cloudflare KV is a global key-value store designed for read-heavy workloads at the edge. Store configuration, feature flags, and static data that's available in milliseconds worldwide.
Why KV for Edge Applications
A developer needed to serve feature flags to users globally. Redis added 50ms+ latency from centralized servers. Cloudflare KV serves data from the nearest edge location — sub-millisecond reads everywhere.
Key Features:
- Global Distribution — Data replicated to 300+ edge locations
- Sub-Millisecond Reads — Served from nearest edge
- Eventually Consistent — Writes propagate globally in ~60 seconds
- Large Values — Up to 25MB per value
- Free Tier — 100K reads/day, 1K writes/day
Quick Start
// wrangler.toml
// [[kv_namespaces]]
// binding = "MY_KV"
// id = "your-namespace-id"
export default {
async fetch(request, env) {
// Write
await env.MY_KV.put("user:123", JSON.stringify({ name: "Alice" }))
// Read
const user = await env.MY_KV.get("user:123", "json")
return Response.json(user)
}
}
With Expiration
// Expires in 1 hour
await env.MY_KV.put("session:abc", token, { expirationTtl: 3600 })
List Keys
const { keys } = await env.MY_KV.list({ prefix: "user:" })
Why Choose Cloudflare KV
- Global by default — data near every user
- Simple API — get, put, delete, list
- Free tier — 100K reads/day
Check out KV docs to get started.
Need edge solutions? Check out my Apify actors or email spinov001@gmail.com for custom solutions.
Top comments (0)