Expand description
Per-account RAM cache for Community sync state.
Holds the page cursors (oldest back-paging floor + newest since floor), history-start flags,
in-flight page de-dup, and the invite preload. All of it is keyed by this account’s channel
ids, so it lives on the account’s session and goes when that does — there is no invalidation
step to get right.
Functions§
- abort_
preload - The warm-up fetch failed/was cancelled — drop the entry so an adopter falls back immediately.
- advance_
newest_ cursor - Advance the latest-page
sincefloor to the newest wire time this page returned (monotonic — only ever steps forward). Call ONLY for latest-page fetches. - advance_
oldest_ cursor - Advance the back-paging cursor to the oldest wire time this page returned (monotonic — only ever steps further back).
- begin_
preload - Mark a community’s warm-up as in-flight (so a racing Join adopts it rather than double-fetching). Evicts expired entries and, if over the cap, the oldest.
- clear
- Drop all cached state. A swap needs no call: this belongs to the account’s session and goes with it. Kept for callers that want a cold cache within one account (tests, an explicit resync).
- clear_
channel_ floors - Clear a channel’s back-paging floors (history-start + oldest cursor) — e.g. after a multi-epoch backfill makes older history reachable again.
- clear_
channel_ sync_ state - Drop ALL of a channel’s sync state (floors + the latest-page
sincecursor) — community teardown. A survivingsincecursor makes a same-session REJOIN sync “since I left” instead of cold, so the rejoined chat opens empty despite plenty of history. - end_
page_ fetch - Release an in-flight page-fetch claim (success or error).
- finish_
preload - The warm-up fetch landed — make its page available to promote/adopt.
- is_
at_ history_ start - Has the channel’s network history-start been reached? Older pages then stay DB-only.
- mark_
history_ start - Mark the channel as having reached its network history-start.
- newest_
cursor - Newest OUTER created_at (seconds) seen on a latest page for the channel — the
sincefloor for the next latest fetch.Nonebefore the first latest fetch this session (→ full newest page). - oldest_
cursor - Oldest OUTER created_at (seconds) fetched for the channel — the back-paging cursor.
- take_
or_ await_ preload - Adopt a community’s warm-up as this sync’s page: Ready → take it; Pending → await it (the
in-flight fetch IS the page, so this waits only the request’s remaining time, never firing a
second); absent/stale/failed →
Noneso the caller fetches normally. Polls at coarse granularity (imperceptible vs. a fresh round-trip) to stay free of notification races. - take_
ready_ preload - Non-blocking take for promotion at Accept: returns the page ONLY if already Ready, leaving a
still-Pending warm-up in place for the sync to adopt.
Noneif absent / Pending / stale. - try_
begin_ page_ fetch - Claim an in-flight page fetch (key
"{channel_id}:{older|latest}"). Returnsfalseif one is already running — the caller should no-op. Pair withend_page_fetch.