Features
- Globally distributed key-value store
- Low-latency reads from 300+ edge locations
- TTL-based expiration for cache patterns
- Native integration with Cloudflare Workers
Pros
- Extremely low read latency at the edge
- Simple API with Workers binding
- Generous free tier (100K reads/day)
Cons
- Eventually consistent (reads may be stale)
- Write propagation takes up to 60 seconds globally
- Value size limited to 25MB
Overview
Cloudflare KV is a globally distributed key-value store designed for read-heavy workloads at the edge. Data written to KV is replicated across Cloudflare’s 300+ edge locations, enabling low-latency reads from anywhere in the world.
KV follows an eventually consistent model: writes are immediately visible at the edge location where they occur, then propagate globally within approximately 60 seconds. This makes it ideal for data that is read frequently but updated infrequently, such as configuration, feature flags, user sessions, and cached content.
KV integrates natively with Cloudflare Workers through bindings, providing a simple get/put/delete API. Each key-value pair can include metadata and an optional TTL for automatic expiration.
When to Use
Choose Cloudflare KV for read-heavy, write-light data that benefits from global edge distribution. It is perfect for configuration, feature flags, cached API responses, and session data in Cloudflare Workers applications.
Getting Started
// In a Cloudflare Worker
export default {
async fetch(request: Request, env: Env) {
await env.MY_KV.put('key', 'value')
const value = await env.MY_KV.get('key')
return new Response(value)
}
}