[READ-ONLY] Mirror of https://github.com/flo-bit/contrail. atproto backend in a bottle flo-bit.dev/contrail/
0

Configure Feed

Select the types of activity you want to include in your feed.

cache known users for warm starts

Florian (Mar 19, 2026, 12:46 PM +0100) 33c8fea7 e5ebcc4e

+16 -5
+2 -1
src/core/backfill.ts
··· 101 101 try { 102 102 client = await withRetry( 103 103 () => getClient(did as Did, db), 104 - `getClient(${did})` 104 + `getClient(${did})`, 105 + 1 105 106 ); 106 107 } catch (err) { 107 108 await markFailed(db, did, collection, String(err));
+14 -4
src/core/jetstream.ts
··· 6 6 7 7 const BATCH_SIZE = 50; 8 8 9 + // Cache known DIDs in memory across ingest cycles (survives within the same Worker isolate) 10 + let cachedKnownDids: Set<string> | undefined; 11 + 9 12 export async function ingestEvents( 10 13 config: ContrailConfig, 11 14 cursor: number | null, ··· 103 106 let knownDids: Set<string> | undefined; 104 107 105 108 if (dependentCollections.length > 0) { 106 - const result = await db 107 - .prepare("SELECT did FROM identities") 108 - .all<{ did: string }>(); 109 - knownDids = new Set((result.results ?? []).map((r) => r.did)); 109 + if (cachedKnownDids) { 110 + knownDids = cachedKnownDids; 111 + console.log(`Using cached known DIDs (${knownDids.size} users)`); 112 + } else { 113 + const result = await db 114 + .prepare("SELECT did FROM identities") 115 + .all<{ did: string }>(); 116 + knownDids = new Set((result.results ?? []).map((r) => r.did)); 117 + cachedKnownDids = knownDids; 118 + console.log(`Loaded ${knownDids.size} known DIDs from database`); 119 + } 110 120 } 111 121 112 122 const { events, lastCursor } = await ingestEvents(