Sled State Store
Q-OS uses sled as its primary embedded database. Sled is a high-performance, embedded, lock-free Bw-Tree. It acts as the single source of truth for edge node state.
#Why Sled over SQLite?
While SQLite is the gold standard for embedded databases, Q-OS opts for Sled due to its raw Key-Value performance and lock-free concurrency model. WASM modules execute extremely quickly (often under 2ms). A relational query engine adds unnecessary overhead when modules only need rapid byte-array retrieval and atomic CAS (Compare-And-Swap) operations for state counters.
#Key Namespace Conventions
Because Sled is a flat Key-Value store, Q-OS enforces logical separation via prefixing. WASM modules should use predictable, namespaced keys to avoid collisions.
#Atomic Operations
Physical events happen concurrently. Ten people might scan a QR code simultaneously. Q-OS guarantees that qos_sdk::state::set operations are handled sequentially by Sled's transaction engine, ensuring no race conditions occur when incrementing counters or decrementing inventory.
💡 TIP