cloudflare / workerd

The JavaScript / Wasm runtime that powers Cloudflare Workers

Home Page:https://blog.cloudflare.com/workerd-open-source-workers-runtime/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Feature request: an API to list only the keys in storage, not their values?

nvie opened this issue · comments

Sometimes it would be useful to only list the "keys" using the Transactional Storage API, and not also having to retreive all of their values. If there are many entries, and they all have a lot of data in their values, then doing a .list() can potentially read N * 128 KiB of unneeded data into memory, which would only be discarded.

For example:

await state.storage.list({ prefix, startAfter, limit, /* etc etc */ });
// new Map([['foo', 'value1'], ['bar', 'value2']])

await state.storage.keys({ prefix, startAfter, limit, /* etc etc */ });
// ['foo', 'bar']