All skills
Skillintermediate

Cloudflare Workers KV

Globally-distributed, eventually-consistent key-value store optimized for high read volume and low latency.

Claude Code Knowledge Pack7/10/2026

Overview

Cloudflare Workers KV

Globally-distributed, eventually-consistent key-value store optimized for high read volume and low latency.

Overview

KV provides:

  • Eventual consistency (60s global propagation)
  • Read-optimized performance
  • 25 MiB value limit per key
  • Auto-replication to Cloudflare edge
  • Metadata support (1024 bytes)

Use cases: Config storage, user sessions, feature flags, caching, A/B testing

When to Use KV

NeedRecommendation
Strong consistencyDurable Objects
SQL queriesD1
Object storage (files)R2
High read, low write volume→ KV ✅
Sub-10ms global reads→ KV ✅

Quick comparison:

FeatureKVD1Durable Objects
ConsistencyEventualStrongStrong
Read latency<10ms~50ms<1ms
Write limit1/s per keyUnlimitedUnlimited
Use caseConfig, cacheRelational dataCoordination

Quick Start

wrangler kv namespace create MY_NAMESPACE
# Add binding to wrangler.jsonc
// Write
await env.MY_KV.put("key", "value", { expirationTtl: 300 });

// Read
const value = await env.MY_KV.get("key");
const json = await env.MY_KV.get("config", "json");

Core Operations

MethodPurposeReturns
get(key, type?)Single read`string \
get(keys, type?)Bulk read (≤100)`Map<string, T \
put(key, value, options?)WritePromise<void>
delete(key)DeletePromise<void>
list(options?)List keys{ keys, list_complete, cursor? }
getWithMetadata(key)Get + metadata{ value, metadata }

Consistency Model

  • Write visibility: Immediate in same location, ≤60s globally
  • Read path: Eventually consistent
  • Write rate: 1 write/second per key (429 on exceed)

Reading Order

TaskFiles to Read
Quick startREADME → configuration.md
Implement featureREADME → api.md → patterns.md
Debug issuesgotchas.md → api.md
Batch operationsapi.md (bulk section) → patterns.md
Performance tuninggotchas.md (performance) → patterns.md (caching)

In This Reference

  • configuration.md - wrangler.jsonc setup, namespace creation, TypeScript types
  • api.md - KV methods, bulk operations, cacheTtl, content types
  • patterns.md - Caching, sessions, rate limiting, A/B testing
  • gotchas.md - Eventual consistency, concurrent writes, value limits

See Also

  • workers - Worker runtime for KV access
  • d1 - Use D1 for strong consistency needs
  • durable-objects - Strongly consistent alternative