Jens
07/14/2021, 8:33 AMkenton
07/14/2021, 2:41 PMWallacy
07/14/2021, 5:15 PMkenton
07/14/2021, 5:44 PMlet promise1 = kv.read(key1);
let promise2 = kv.read(key2);
let value1 = await promise1;
let value2 = await promise2;
Amenadiel
07/14/2021, 5:46 PMkenton
07/14/2021, 5:47 PMkv.get(key, "stream")
, this returns a ReadableStream
that you can use as your response body. Similarly kv.put(key, request.body)
will stream a request into KV without reading it into memory. (These apply to Workers KV, not durable object storage.)kenton
07/14/2021, 5:49 PMlist()
to fetch a few keys at a time. Since each value can't be more than 32k, you would have to split large blobs across several keys.Amenadiel
07/14/2021, 5:49 PMfiggyc
07/14/2021, 5:51 PMPromise.all
js
let promises = [kv.read(key1), kv.read(key2)] // and so on - plus you could like generate this array
let values = await Promise.all(promises)
console.log(values)
// -> ["value1", "value2"]
figgyc
07/14/2021, 5:52 PMWallacy
07/14/2021, 6:38 PMWallacy
07/14/2021, 6:39 PMWallacy
07/14/2021, 6:41 PMAmenadiel
07/14/2021, 9:02 PMjohn.spurlock
07/14/2021, 9:07 PMVanessa🦩
07/14/2021, 9:09 PMkenton
07/14/2021, 9:56 PMawait
all writes (this will apply backpressure as needed). But the amount of memory your isolate is using, and the amount of memory the cache is using, are at present not connected; the limit is applied separately to each, not the sum total. We might link them more closely in the future, but if so what we'd do is make the cache automatically evict entries as needed so that the total memory usage stays within the limit.kenton
07/14/2021, 9:58 PMawait
your `put()`s (but that only matters in unusual scenarios).Vanessa🦩
07/14/2021, 10:16 PMkenton
07/14/2021, 10:22 PMkenton
07/14/2021, 10:25 PMput(key, value, {allowUnconfirmed: true})
Vanessa🦩
07/14/2021, 10:29 PMjohn.spurlock
07/14/2021, 10:31 PMkenton
07/14/2021, 10:31 PMkenton
07/14/2021, 10:31 PMkenton
07/14/2021, 10:31 PMjohn.spurlock
07/14/2021, 10:33 PMkenton
07/15/2021, 4:22 PMWallacy
07/15/2021, 4:31 PMckoeninger
07/15/2021, 4:41 PM