Core concepts
Topic state, session state, and cache
Compare shared topic maps, per-socket session maps, and distributed cache tables.
Shared topic state (events:<topic>)
- Updated with
set_stateon the channel orPUT /api/server/v1/topics/:topic/stateover HTTP. - Broadcasts
state_updatedonly when the stored JSON map actually changes — identical payloads are acknowledged without a broadcast. - Visible to every subscriber on that topic.
Session state (session channel)
- Updated with
set_session_state/ read withget_session_state. - Private to the websocket connection — other clients never see it.
- Reconnecting starts from an empty session until you set values again.
Distributed cache (/api/cache/* or session cache events)
- Organized by
tableandkeystring identifiers with arbitrary JSON-compatible values. setdata/set_cache_datareplaces the entire stored value for that key.updatedata/update_cache_datashallow-merges a JSONpatchobject into an existing object value (add or overwrite top-level keys). It does not create keys from scratch; usesetdatafor inserts or full replacement.- Optional
ttl_mson writes and updates, bounded by server configuration. - Errors such as
rehydrating,rpc_failed, andshard_unavailablemirror across HTTP and websocket replies; partial updates can also returnnot_found,invalid_patch, orvalue_not_mergeable.
Use topic state when you want room semantics with broadcasts. Use cache when you want durable-ish key/value semantics routed through the cache layer.