Deno KV is a built-in key-value store using tuple-based hierarchical keys and atomic transactions with optimistic concurrency control. Master vocabulary for key part arrays, prefix-based listing, versionstamp-based check-and-set atomics, the watch() ReadableStream, structured clone value serialization, and storage location defaults.
0 / 5 completed
1 / 5
A developer opens a Deno KV store with const kv = await Deno.openKv() without arguments. Where is the database stored?
When called without a path argument, Deno KV stores data in a platform-specific persistent location derived from the script's path (e.g., under DENO_DIR/kv/). This persists across process restarts. Pass an explicit path string (or ':memory:' for in-memory) to control storage location.
2 / 5
A developer calls kv.set(['users', userId], userData) followed by kv.set(['users', userId, 'profile'], profileData). What does this demonstrate about Deno KV keys?
Deno KV keys are tuples (arrays) of key parts forming a hierarchical namespace. Each unique tuple is an independent key — ['users', id] and ['users', id, 'profile'] are distinct entries. The tuple structure enables efficient prefix-based listing: kv.list({ prefix: ['users', id] }) retrieves all entries under that prefix.
3 / 5
A Deno KV atomic transaction includes a .check() call. What does this enable?
kv.atomic().check({ key, versionstamp }).set(key, newValue).commit() implements optimistic concurrency control. The transaction only commits if the key's current versionstamp matches the checked value (read earlier). If another process modified the key in the meantime, the transaction aborts, and the caller must retry. Pass null as versionstamp to check that the key doesn't exist.
4 / 5
A developer uses kv.watch([key]) to observe changes to a KV entry. What does this return?
kv.watch(keys) returns a ReadableStream that emits an array of KvEntryMaybe (one per watched key) whenever any watched key changes. Consumers iterate the stream with for await (const entries of stream). On Deno Deploy, this is backed by a distributed event system.
5 / 5
Deno KV stores a Uint8Array as a value. When retrieved, what type does the .value property have?
Deno KV uses the structured clone algorithm for serialization, which preserves JavaScript types including TypedArray, Map, Set, Date, etc. A Uint8Array is stored and retrieved as a Uint8Array. This is more expressive than JSON serialization, which cannot represent typed arrays natively.