B7.3.1 · dive 1 of 3 · module B7.3
The guess and the lock.
A guess is six distinct codes, checked against the game’s set from the cache; a short-lived Valkey lock allows one move in flight per player, and an invalid or locked guess is refused before any charge.
The idea
codemojex · the guess and the lockA guess is six codes in fixed positions, and before anything else it is checked: six of them, distinct, each addressing a cell in the game’s emoji set. A guess that fails the check never reaches the lane and is never charged. The check reads the set from the cache under the game’s version, so it costs no round trip on the hot path.
A player may have one guess in flight at a time. The reference implementation takes a short-lived lock in Valkey, keyed by the player and the game, so a double tap or a retry cannot enqueue the same guess twice or charge twice for one move. The lock is held only across the validate, charge, and enqueue step, and released the moment the job is on the lane.
Locks and lanes both live in the Valkey tier, the layer the system treats as reconstructable. A lock lost on a node restart costs at most a brief window where a duplicate could slip through, and idempotency on the charge closes that gap. The record of truth — the wallet and the secret — is on Postgres; the lock is a coordination hint, not the ledger.
The doors
the sibling coursesEchoMQ — the protocol, in depth
The bus B3 narrates, taught rung by rung: the keyspace, the Lua inventory, and the 3.0 Stream Tier — XADD, XREADGROUP, XACK — with conformance on Valkey.
Redis Patterns Applied
The substrate patterns under the bus: sorted sets, atomic Lua moves, locks, and streams — the judgement layer.
/echo-persistenceEcho Persistence — the durable floor
Beneath the volatile tiers: the Graft page engine built twice, the commit-LSN loop, and the stream archive on Tigris. Where Part I says state lives somewhere, this says where it lives durably.
References
sources · relatedSources
- Helland — Life Beyond Distributed Transactions (CIDR 2007)a guess as a message about identities, carrying ids rather than the secret
- Erlang/OTP — the gen_server behaviourthe validator and the score worker as processes behind a boundary
- Erlang/OTP — the ets modulethe read-hot cache the validator and the worker read the secret from
Related
- BCS — the course homethe law, the id anatomy, the chapter map
- Echo Persistencethe durable floor beneath the bus