Skip to main content
State in iii is a distributed key-value store addressed by scope (group) + key (item ID). Any worker can read and write state by triggering state::get, state::set, state::delete, and state::list through the engine.

Writing state

Reading state

Batch read with state::list

state::list returns all keys in a scope — useful in cron jobs that sweep over accumulated data.

State API reference

Key concepts

  • State is addressed by scope (equivalent to groupId in streams) and key (item ID). Use scope as a logical namespace ("users", "orders") and key as the unique identifier within it.
  • state::list returns all items in a scope as an array. Use it sparingly in hot paths; it’s best suited for cron-driven batch sweeps.
  • State is separate from named streams. Streams have real-time WebSocket push; state does not.
  • Unlike streams, state has no update semantics — to modify a record, read it first then write the merged result back with state::set.