Skip to content

Store job results

This example groups a result, status and removal of a pending marker in one namespace batch. Use the quickstart to create the disk and obtain a project API key.

Terminal window
curl --fail-with-body --no-buffer \
"https://api.wabe.sh/v1/disks/demo/exec?kind=js" \
-H "Authorization: Bearer YOUR_PROJECT_API_KEY" \
--data-binary @- <<'JS'
const jobs = kv.namespace('jobs');
await jobs.batch([
{op:'put', key:'42:result', value:{files:3, warnings:0}},
{op:'put', key:'42:status', value:'done'},
{op:'delete', key:'42:pending'},
]);
await fs.flush();
return {id:'42', status:await jobs.get('42:status')};
JS

The batch publishes its mutations together. This recipe explicitly waits for disk persistence before returning. A disconnect can still leave the mutation applied; inspect the recorded job before retrying.

Terminal window
curl --fail-with-body "https://api.wabe.sh/v1/disks/demo/kv/jobs" \
-H "Authorization: Bearer YOUR_PROJECT_API_KEY" \
--json '{"op":"get","key":"42:result"}'
Value in the returned entry
{"type":"json","value":{"files":3,"warnings":0}}
Terminal window
curl --fail-with-body --no-buffer "https://api.wabe.sh/v1/disks/demo/kv/jobs" \
-H "Authorization: Bearer YOUR_PROJECT_API_KEY" \
--json '{"op":"scan","prefix":"42:"}'

One scan reads the job’s result and status in its scan view. Separate get calls can observe intervening writes. The API has no compare-and-set, lock or queue primitive. See KV semantics before building a job dispatcher.