B2.2.2 · dive 2 of 3 · module B2.2
Key order is time order.
Snowflakes are minted in time order and base62 preserves it, so the ordered_set is sorted by time for free. Latest-N, windows, and cursors are range operations on the key.
The idea
echo_data · timeline.ex, property_store.exSnowflakes are minted in time order, and base62 preserves that order byte for byte, so the ordered_set’s key order is chronological order — for free, with no clock column and no sort. EchoData.Timeline turns this into its whole API: latest-N, cursor pagination, and time-window counts are all range operations on the key.
Three reads fall out of one property. Latest-N walks back from the table’s last key; a window is an :ets.select over a half-open range of ids; and a time bound needs no stored id at all, because EchoData.Snowflake.min_for mints a synthetic cursor for any instant — everything since two o’clock becomes a key comparison. The branded id even doubles as the public pagination token: opaque-looking, URL-safe, and exact to resume from.
Codemojex reads its history this way. A room’s recent guesses are latest-N off the keyspace; a leaderboard over the last hour is a window between two synthetic cursors; a feed resumes from the last id the client saw. None of it stores a timestamp, because the id is the timestamp, and the keyspace is already sorted.
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
- King — Announcing Snowflake (2010)time-ordered ids whose key order is mint order
- Kreps — The Log (LinkedIn Engineering)time-ordered, append-only data and rebuilding state by replaying it
- Erlang/OTP — the ets modulethe ordered_set whose key order is range-queryable without a sort
Related
- BCS — the course homethe law, the id anatomy, the chapter map
- Echo Persistencethe durable floor beneath the bus