Fastest way to fetch all KV keys in namespace


I’m currently fetching all keys in a namespace using the generator below.

Is there a faster way to “bulk fetch” all keys in a namespace? Can this be parallelized somehow?

foobar: async function* () {
  let cursor = true

  while (cursor) {
    const list = await FOOBAR.list(
      cursor === true ? {} : { cursor: cursor }

    cursor = list.list_complete ? false : list.cursor

    for (const key of list.keys) {
      yield await FOOBAR.get(, 'json')
1 Like

If you do not need all the data stored, or your data is small, you could try to save it (or a portion of it) as metadata. In this case, LIST operation will get you everything in one request. There is no bulk GET, unfortunately…

Interesting. What are the limits of metadata?

I’m storing about 250-300 characters of JSON as the value currently:


AFAIK, the metadata limits are not documented (maybe somebody could correct me?). For the data in your example, I think you can store it whole as metadata. You should test, though.

It’s 1024 bytes per key:

1 Like