The Key-Value Store enables you to store and retrieve small chunks of serializable data in and outside of your Jobs.

Use the io.store object to access namespaced stores inside of your Run functions. Or use client.store to access the environment store anywhere in your app!

Sharing data across Runs with io.store.job:


client.defineJob({
...
run: async (payload, io, ctx) => {
// this will only be undefined on the first run
const counter = await io.store.job.get<number>("job-get", "counter")
const currentCount = counter ?? 0
const incrementedCounter = currentCount++
// Job-scoped set
await io.store.job.set("job-set", "counter", incrementedCounter);
}
})

Sharing data across Jobs with io.store.env:


client.defineJob({
id: "job-1",
...
run: async (payload, io, ctx) => {
// store data in one job
await io.store.env.set("cacheKey", "cross-run-shared-key", { foo: "bar" });
}
})
client.defineJob({
id: "job-2",
...
run: async (payload, io, ctx) => {
// access from a different job
const value = await io.store.env.get<{ foo: string }>("cacheKey", "cross-run-shared-key");
}
})
// or anywhere else in your app
await client.store.env.get<{ foo: string }>("cross-run-shared-key");

Full docs for io.store and client.store.

Ready to start building?

Build and deploy your first task in 3 minutes.

Get started now