|
6 | 6 |
|
7 | 7 | **Keyval** is a small key/value storage layer with a consistent API across environments and backends: |
8 | 8 |
|
9 | | -* **In-memory** (fast, ephemeral) |
10 | | -* **Browser storage** (WebStorage, IndexedDB, Cookie Store) |
11 | | -* **File storage** (Node.js) |
12 | | -* **Redis** (shared server-side storage) |
| 9 | +* **In-memory backend** (fast, ephemeral) |
| 10 | +* **Browser storage backend** (WebStorage, IndexedDB, Cookie Store) |
| 11 | +* **File storage backend** (Node.js) |
| 12 | +* **Redis backend** (shared server-side storage) |
13 | 13 |
|
14 | 14 | It gives you a simple dictionary API for state—regardless of where that state physically lives. |
15 | 15 |
|
@@ -113,24 +113,23 @@ await kv.set('flags', { beta: true }); |
113 | 113 | But Keyval diverges from the `Map` contract in a few ways: |
114 | 114 |
|
115 | 115 | * Methods are async. |
116 | | -* An async `.count()` method as the equivalent of `Map.size`. |
| 116 | +* An async `.count()` method is the equivalent of `Map.size`. |
117 | 117 | * No `.forEach()` method. You use `.entries()` instead. |
118 | 118 |
|
119 | 119 | And Keyval extends the contract with additional methods like `.observe()`, `.close()`, etc. |
120 | 120 |
|
121 | 121 | ### 3. Field metadata |
122 | 122 |
|
123 | | -Keyval ensures a transparent mapping between what you set and what you get. But internally, each key is held as a **metadata object** containing the actual value and optional metadata. This typically looks like: |
| 123 | +Keyval ensures a transparent mapping between what you set and what you get. But internally, each key is held as a **metadata object** containing the actual value and optional user-supplied metadata. This typically looks like: |
124 | 124 |
|
125 | 125 | ```ts |
126 | 126 | { |
127 | 127 | value: any, |
128 | | - expires?: number, |
129 | | - ...metadata |
| 128 | + ...meta |
130 | 129 | } |
131 | 130 | ``` |
132 | 131 |
|
133 | | -This makes it possible to support field-level metadata (e.g. field-level expiry, etc.) when needed: |
| 132 | +This makes it possible to support field-level metadata when needed: |
134 | 133 |
|
135 | 134 | ```js |
136 | 135 | kv.set('key1', 22); |
|
0 commit comments