[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill-trigger-dev-staff-engineering-skills-consistency-models":3,"mdc--95552w-key":37,"related-org-trigger-dev-staff-engineering-skills-consistency-models":3979,"related-repo-trigger-dev-staff-engineering-skills-consistency-models":4145},{"slug":4,"name":4,"fn":5,"description":6,"org":7,"tags":12,"stars":26,"repoUrl":27,"updatedAt":28,"license":29,"forks":30,"topics":31,"repo":32,"sourceUrl":35,"mdContent":36},"staff-engineering-skills-consistency-models","manage consistency models in distributed systems","Prevent stale read bugs caused by replica lag, cache staleness, and index delay. Use when writing code that reads data after writing it, uses read replicas, caches query results, reads from search indexes, or builds event-driven read models. Activates on patterns like create-then-redirect, update-then-read, cache-aside with TTL, search-after-create, or any write followed by a read that might hit a different data source.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},"trigger-dev","Trigger.dev","https:\u002F\u002Fpexgzepcugksgbtrxkhf.supabase.co\u002Fstorage\u002Fv1\u002Fobject\u002Fpublic\u002Forg-logos\u002Ftrigger-dev.jpg","triggerdotdev",[13,17,20,23],{"name":14,"slug":15,"type":16},"Performance","performance","tag",{"name":18,"slug":19,"type":16},"Architecture","architecture",{"name":21,"slug":22,"type":16},"Database","database",{"name":24,"slug":25,"type":16},"Engineering","engineering",3,"https:\u002F\u002Fgithub.com\u002Ftriggerdotdev\u002Fstaff-engineering-skills","2026-06-17T08:40:46.442182",null,1,[],{"repoUrl":27,"stars":26,"forks":30,"topics":33,"description":34},[],"Skills that give AI   coding agents staff-engineer instincts: recognizing and avoiding production failure modes like cardinality, idempotency, and race conditions.","https:\u002F\u002Fgithub.com\u002Ftriggerdotdev\u002Fstaff-engineering-skills\u002Ftree\u002FHEAD\u002Fskills\u002Fstaff-engineering-skills-consistency-models","---\nname: staff-engineering-skills-consistency-models\ndescription: Prevent stale read bugs caused by replica lag, cache staleness, and index delay. Use when writing code that reads data after writing it, uses read replicas, caches query results, reads from search indexes, or builds event-driven read models. Activates on patterns like create-then-redirect, update-then-read, cache-aside with TTL, search-after-create, or any write followed by a read that might hit a different data source.\n---\n\n# Consistency Models Trap\n\nYou wrote data. You read it back. You got the old value. Before writing any code that reads after writing, ask: **could the read hit a different instance than the write?**\n\n## The Three Consistency Gaps\n\nAlmost every consistency bug has the same shape: data written to system A, read from system B, and B hasn't caught up.\n\n| Gap | What happens | Typical delay |\n|-----|-------------|---------------|\n| **Replica lag** | Write to primary, read hits replica | 10-500ms (async replication) |\n| **Cache staleness** | Write to database, read hits cache | Seconds to minutes (TTL-based) |\n| **Index delay** | Write to database, search reads index | 1-30s (Elasticsearch, Algolia) |\n\n## Detection: Write-Then-Read Patterns\n\n**Stop and check consistency if you see:**\n\n1. **Create\u002Fupdate then redirect to a page that reads the same data** -- the page load may hit a replica; user sees old data and thinks the save failed.\n2. **Database write then cache read on the next request** -- cache still has the old value. Worse if the cache was populated from a replica.\n3. **Database write then search** -- \"I just created this, where is it?\" The index hasn't indexed it yet.\n4. **Event published then read model queried** -- consumer hasn't processed it. \"Order not found\" on the confirmation page.\n5. **Database write then `findMany` that should include the new record** -- if `findMany` hits a replica, the new record may be missing.\n6. **Any UI flow: mutate → navigate → display** -- if display reads from a different source than the mutate, there's a gap.\n\n## Not Everything Needs Strong Consistency\n\nThe fix is NOT \"make everything strongly consistent\" -- that's expensive and usually unnecessary. **Route reads to the appropriate backend based on freshness requirements.**\n\n| Read type | Consistency needed | Source |\n|-----------|-------------------|--------|\n| User viewing own data after editing | Strong (read-after-write) | Primary, or return written data |\n| Browsing other users' content | Eventual | Read replica, cache |\n| Full-text search results | Eventual | Search index |\n| Dashboard analytics | Eventual | Read replica, materialized view |\n| Account balance after transfer | Strong | Primary, write-through cache |\n| \"My recent orders\" after placing one | Strong (read-after-write) | Primary or optimistic UI |\n\n## Patterns\n\n### Return the written data (simplest, best)\n\n```typescript\napp.post(\"\u002Fapi\u002Fprofile\", async (req, res) => {\n  const updated = await db.user.update({\n    where: { id: req.user.id },\n    data: { name: req.body.name, bio: req.body.bio },\n  });\n  res.json(updated); \u002F\u002F Return what we wrote. No second read needed.\n});\n```\n\nNo read-after-write means no consistency problem. Best pattern whenever the API can return the mutated entity.\n\n### Optimistic UI (client-side)\n\n```typescript\nasync function updateProfile(data: ProfileUpdate) {\n  setLocalProfile(prev => ({ ...prev, ...data })); \u002F\u002F Show immediately\n\n  const response = await fetch(\"\u002Fapi\u002Fprofile\", {\n    method: \"PUT\",\n    body: JSON.stringify(data),\n  });\n\n  if (!response.ok) {\n    setLocalProfile(previousProfile); \u002F\u002F Revert on failure\n    showError(\"Failed to save\");\n  }\n  \u002F\u002F Don't re-fetch. Trust local state. Others see it when read models catch up.\n}\n```\n\nThe writer sees the change immediately -- no round-trip, no gap. Standard for modern SPAs.\n\n### Read from primary after write\n\n```typescript\napp.post(\"\u002Fapi\u002Fprofile\", async (req, res) => {\n  await db.user.update({ where: { id: req.user.id }, data: req.body });\n  res.cookie(\"_read_primary\", \"1\", { maxAge: 5000 }); \u002F\u002F tell read path to use primary\n  res.redirect(`\u002Fprofile\u002F${req.user.id}`);\n});\n\napp.get(\"\u002Fprofile\u002F:id\", async (req, res) => {\n  const forcePrimary = req.cookies._read_primary === \"1\";\n  const user = await db.user.findUnique({\n    where: { id: req.params.id },\n    ...(forcePrimary && { replicaRead: false }), \u002F\u002F framework-specific\n  });\n  res.render(\"profile\", { user });\n});\n```\n\nOnly the user who wrote gets the primary read; once the cookie expires, reads return to replicas. Everyone else stays on replicas throughout.\n\n### Write-through cache\n\n```typescript\nasync function updateUser(userId: string, data: Partial\u003CUser>) {\n  const updated = await db.user.update({ where: { id: userId }, data });\n  \u002F\u002F Set cache to the known-correct value, don't just delete it.\n  await redis.set(`user:${userId}`, JSON.stringify(updated), \"EX\", 300);\n  return updated;\n}\n```\n\nWrite-through beats delete-then-repopulate: if you delete the key, the next request can read from a stale replica and repopulate with old data.\n\n### Separate \"my stuff\" from \"browse\u002Fsearch\"\n\n```typescript\napp.get(\"\u002Fapi\u002Fdocuments\", async (req, res) => {\n  if (req.query.q) {\n    \u002F\u002F Search: index (eventual, expected for search)\n    res.json(await searchIndex.search(\"documents\", req.query.q));\n  } else if (req.query.mine) {\n    \u002F\u002F My documents: primary (strong for own data)\n    res.json(await db.document.findMany({\n      where: { authorId: req.user.id }, orderBy: { createdAt: \"desc\" },\n    }));\n  } else {\n    \u002F\u002F Browse all: replica (eventual, fine for discovery)\n    res.json(await readReplica.document.findMany({\n      orderBy: { createdAt: \"desc\" }, take: 50,\n    }));\n  }\n});\n```\n\nDifferent reads, different consistency requirements, different backends.\n\n## Know Your Database's Consistency Model\n\nEvery database has a default consistency model. Assume stronger guarantees than you have and you'll write stale-read bugs. Defaults and the trap for each:\n\n- **PostgreSQL** -- Strong on a single instance. Streaming (async) replication is the standard HA setup, with 10-500ms replica lag; synchronous replication removes lag but adds write latency. *Trap:* Prisma\u002FRails\u002FDjango can transparently route reads to replicas -- your ORM may read a replica without you knowing.\n- **MySQL \u002F Aurora MySQL** -- Strong on single instance. Aurora replicas lag ~10-20ms (shared storage); standard async replicas lag seconds-to-minutes under load. Aurora reader-endpoint affinity can route post-write reads to the writer. *Trap:* cluster endpoint (writes) vs reader endpoint (replicas) -- a reader connection string means you're reading replicas.\n- **Redis** -- Eventual with async replication; no guarantee a replica has the latest write. *Trap:* stale cache reads from replicas are by design; for coordination (locks, rate limiting) always read\u002Fwrite the primary.\n- **ClickHouse** -- Eventual; built for analytics where slight staleness is fine. Inserts are async by default (local buffer, async replication), so a query right after insert may miss the data. `insert_quorum` forces synchronous writes to N replicas; `select_sequential_consistency=1` forces reads to wait for latest -- both expensive. ReplicatedMergeTree still replicates async. MergeTree merges run in the background, so queries can see duplicate rows until merge completes unless you use `ReplacingMergeTree` with `FINAL` (or `OPTIMIZE TABLE ... FINAL`, expensive). *Trap:* write-then-immediately-query works single-node in dev, fails with distributed tables in prod -- assume reads are stale unless quorum writes are configured.\n- **MongoDB** -- Eventual with replica sets; secondaries may be stale. Read concern: `\"local\"` (default, may be stale), `\"majority\"`, `\"linearizable\"` (strongest, slowest). *Trap:* default `\"local\"` read + default `w:1` write means you can lose acknowledged writes if the primary fails before replication.\n- **DynamoDB** -- Eventual reads by default; `GetItem`\u002F`Query` need `ConsistentRead: true` (2x read cost) to see the latest. Global tables resolve cross-region conflicts last-writer-wins. *Trap:* SDK defaults give eventual consistency silently -- a `GetItem` that must see a prior `PutItem` needs `ConsistentRead: true`.\n- **Elasticsearch \u002F OpenSearch** -- Near-real-time (eventual): an indexed doc isn't searchable until the next refresh (default 1s; bulk slower). `refresh=wait_for` forces a refresh before returning, at a latency cost. *Trap:* \"just indexed, can't find it\" -- the index hasn't refreshed; consistency is traded for search throughput.\n- **S3** -- Strong read-after-write since 2020: a GET after a successful PUT returns the latest. *Trap:* LIST can still lag -- a newly PUT object may not appear in a LIST immediately. See the Object Store as Database skill for conditional writes.\n\n## Anti-Patterns\n\n```typescript\n\u002F\u002F Dangerous: create then redirect. \u002Forders\u002F:id reads a replica; order may not be there yet.\napp.post(\"\u002Fapi\u002Forders\", async (req, res) => {\n  const order = await db.order.create({ data: req.body });\n  res.redirect(`\u002Forders\u002F${order.id}`);\n});\n\n\u002F\u002F Dangerous: update database, read from cache on next request (stale until TTL expires)\nawait db.user.update({ where: { id }, data: { name: \"New Name\" } });\nconst cached = await redis.get(`user:${id}`); \u002F\u002F still \"Old Name\"\n\n\u002F\u002F Dangerous: create in database, immediately search for it (index hasn't refreshed)\nawait db.document.create({ data: { title: \"Q4 Report\", content: \"...\" } });\nawait searchIndex.index(\"documents\", doc.id, doc);\n\u002F\u002F User searches \"Q4 Report\" -- not found\n\n\u002F\u002F Dangerous: publish event, query read model on next page (consumer hasn't run)\nawait eventBus.publish(\"order.created\", order);\nres.redirect(\"\u002Forders\");\n```\n\n## Related Traps\n\n- **Race Conditions** -- replica lag is a race condition: write to primary, read from replica, decide on stale data. Same fix: read from primary when freshness matters.\n- **Idempotency** -- consistency gaps make users retry (\"my save didn't work, click again\"), creating duplicates. Idempotency prevents the duplicate from causing harm.\n- **Cache Invalidation** -- cache staleness is a consistency problem. Write-through is the consistency-aware pattern; delete-and-repopulate races with a stale-replica refill.\n- **Denormalization** -- every denormalized copy is an eventually consistent read model; the gap is the window between source write and copy update.\n",{"data":38,"body":39},{"name":4,"description":6},{"type":40,"children":41},"root",[42,51,63,70,75,171,177,185,266,272,282,414,420,427,802,807,813,1222,1227,1233,1971,1976,1982,2290,2295,2301,2899,2904,2910,2915,3181,3187,3924,3930,3973],{"type":43,"tag":44,"props":45,"children":47},"element","h1",{"id":46},"consistency-models-trap",[48],{"type":49,"value":50},"text","Consistency Models Trap",{"type":43,"tag":52,"props":53,"children":54},"p",{},[55,57],{"type":49,"value":56},"You wrote data. You read it back. You got the old value. Before writing any code that reads after writing, ask: ",{"type":43,"tag":58,"props":59,"children":60},"strong",{},[61],{"type":49,"value":62},"could the read hit a different instance than the write?",{"type":43,"tag":64,"props":65,"children":67},"h2",{"id":66},"the-three-consistency-gaps",[68],{"type":49,"value":69},"The Three Consistency Gaps",{"type":43,"tag":52,"props":71,"children":72},{},[73],{"type":49,"value":74},"Almost every consistency bug has the same shape: data written to system A, read from system B, and B hasn't caught up.",{"type":43,"tag":76,"props":77,"children":78},"table",{},[79,103],{"type":43,"tag":80,"props":81,"children":82},"thead",{},[83],{"type":43,"tag":84,"props":85,"children":86},"tr",{},[87,93,98],{"type":43,"tag":88,"props":89,"children":90},"th",{},[91],{"type":49,"value":92},"Gap",{"type":43,"tag":88,"props":94,"children":95},{},[96],{"type":49,"value":97},"What happens",{"type":43,"tag":88,"props":99,"children":100},{},[101],{"type":49,"value":102},"Typical delay",{"type":43,"tag":104,"props":105,"children":106},"tbody",{},[107,129,150],{"type":43,"tag":84,"props":108,"children":109},{},[110,119,124],{"type":43,"tag":111,"props":112,"children":113},"td",{},[114],{"type":43,"tag":58,"props":115,"children":116},{},[117],{"type":49,"value":118},"Replica lag",{"type":43,"tag":111,"props":120,"children":121},{},[122],{"type":49,"value":123},"Write to primary, read hits replica",{"type":43,"tag":111,"props":125,"children":126},{},[127],{"type":49,"value":128},"10-500ms (async replication)",{"type":43,"tag":84,"props":130,"children":131},{},[132,140,145],{"type":43,"tag":111,"props":133,"children":134},{},[135],{"type":43,"tag":58,"props":136,"children":137},{},[138],{"type":49,"value":139},"Cache staleness",{"type":43,"tag":111,"props":141,"children":142},{},[143],{"type":49,"value":144},"Write to database, read hits cache",{"type":43,"tag":111,"props":146,"children":147},{},[148],{"type":49,"value":149},"Seconds to minutes (TTL-based)",{"type":43,"tag":84,"props":151,"children":152},{},[153,161,166],{"type":43,"tag":111,"props":154,"children":155},{},[156],{"type":43,"tag":58,"props":157,"children":158},{},[159],{"type":49,"value":160},"Index delay",{"type":43,"tag":111,"props":162,"children":163},{},[164],{"type":49,"value":165},"Write to database, search reads index",{"type":43,"tag":111,"props":167,"children":168},{},[169],{"type":49,"value":170},"1-30s (Elasticsearch, Algolia)",{"type":43,"tag":64,"props":172,"children":174},{"id":173},"detection-write-then-read-patterns",[175],{"type":49,"value":176},"Detection: Write-Then-Read Patterns",{"type":43,"tag":52,"props":178,"children":179},{},[180],{"type":43,"tag":58,"props":181,"children":182},{},[183],{"type":49,"value":184},"Stop and check consistency if you see:",{"type":43,"tag":186,"props":187,"children":188},"ol",{},[189,200,210,220,230,256],{"type":43,"tag":190,"props":191,"children":192},"li",{},[193,198],{"type":43,"tag":58,"props":194,"children":195},{},[196],{"type":49,"value":197},"Create\u002Fupdate then redirect to a page that reads the same data",{"type":49,"value":199}," -- the page load may hit a replica; user sees old data and thinks the save failed.",{"type":43,"tag":190,"props":201,"children":202},{},[203,208],{"type":43,"tag":58,"props":204,"children":205},{},[206],{"type":49,"value":207},"Database write then cache read on the next request",{"type":49,"value":209}," -- cache still has the old value. Worse if the cache was populated from a replica.",{"type":43,"tag":190,"props":211,"children":212},{},[213,218],{"type":43,"tag":58,"props":214,"children":215},{},[216],{"type":49,"value":217},"Database write then search",{"type":49,"value":219}," -- \"I just created this, where is it?\" The index hasn't indexed it yet.",{"type":43,"tag":190,"props":221,"children":222},{},[223,228],{"type":43,"tag":58,"props":224,"children":225},{},[226],{"type":49,"value":227},"Event published then read model queried",{"type":49,"value":229}," -- consumer hasn't processed it. \"Order not found\" on the confirmation page.",{"type":43,"tag":190,"props":231,"children":232},{},[233,247,249,254],{"type":43,"tag":58,"props":234,"children":235},{},[236,238,245],{"type":49,"value":237},"Database write then ",{"type":43,"tag":239,"props":240,"children":242},"code",{"className":241},[],[243],{"type":49,"value":244},"findMany",{"type":49,"value":246}," that should include the new record",{"type":49,"value":248}," -- if ",{"type":43,"tag":239,"props":250,"children":252},{"className":251},[],[253],{"type":49,"value":244},{"type":49,"value":255}," hits a replica, the new record may be missing.",{"type":43,"tag":190,"props":257,"children":258},{},[259,264],{"type":43,"tag":58,"props":260,"children":261},{},[262],{"type":49,"value":263},"Any UI flow: mutate → navigate → display",{"type":49,"value":265}," -- if display reads from a different source than the mutate, there's a gap.",{"type":43,"tag":64,"props":267,"children":269},{"id":268},"not-everything-needs-strong-consistency",[270],{"type":49,"value":271},"Not Everything Needs Strong Consistency",{"type":43,"tag":52,"props":273,"children":274},{},[275,277],{"type":49,"value":276},"The fix is NOT \"make everything strongly consistent\" -- that's expensive and usually unnecessary. ",{"type":43,"tag":58,"props":278,"children":279},{},[280],{"type":49,"value":281},"Route reads to the appropriate backend based on freshness requirements.",{"type":43,"tag":76,"props":283,"children":284},{},[285,306],{"type":43,"tag":80,"props":286,"children":287},{},[288],{"type":43,"tag":84,"props":289,"children":290},{},[291,296,301],{"type":43,"tag":88,"props":292,"children":293},{},[294],{"type":49,"value":295},"Read type",{"type":43,"tag":88,"props":297,"children":298},{},[299],{"type":49,"value":300},"Consistency needed",{"type":43,"tag":88,"props":302,"children":303},{},[304],{"type":49,"value":305},"Source",{"type":43,"tag":104,"props":307,"children":308},{},[309,327,345,362,379,397],{"type":43,"tag":84,"props":310,"children":311},{},[312,317,322],{"type":43,"tag":111,"props":313,"children":314},{},[315],{"type":49,"value":316},"User viewing own data after editing",{"type":43,"tag":111,"props":318,"children":319},{},[320],{"type":49,"value":321},"Strong (read-after-write)",{"type":43,"tag":111,"props":323,"children":324},{},[325],{"type":49,"value":326},"Primary, or return written data",{"type":43,"tag":84,"props":328,"children":329},{},[330,335,340],{"type":43,"tag":111,"props":331,"children":332},{},[333],{"type":49,"value":334},"Browsing other users' content",{"type":43,"tag":111,"props":336,"children":337},{},[338],{"type":49,"value":339},"Eventual",{"type":43,"tag":111,"props":341,"children":342},{},[343],{"type":49,"value":344},"Read replica, cache",{"type":43,"tag":84,"props":346,"children":347},{},[348,353,357],{"type":43,"tag":111,"props":349,"children":350},{},[351],{"type":49,"value":352},"Full-text search results",{"type":43,"tag":111,"props":354,"children":355},{},[356],{"type":49,"value":339},{"type":43,"tag":111,"props":358,"children":359},{},[360],{"type":49,"value":361},"Search index",{"type":43,"tag":84,"props":363,"children":364},{},[365,370,374],{"type":43,"tag":111,"props":366,"children":367},{},[368],{"type":49,"value":369},"Dashboard analytics",{"type":43,"tag":111,"props":371,"children":372},{},[373],{"type":49,"value":339},{"type":43,"tag":111,"props":375,"children":376},{},[377],{"type":49,"value":378},"Read replica, materialized view",{"type":43,"tag":84,"props":380,"children":381},{},[382,387,392],{"type":43,"tag":111,"props":383,"children":384},{},[385],{"type":49,"value":386},"Account balance after transfer",{"type":43,"tag":111,"props":388,"children":389},{},[390],{"type":49,"value":391},"Strong",{"type":43,"tag":111,"props":393,"children":394},{},[395],{"type":49,"value":396},"Primary, write-through cache",{"type":43,"tag":84,"props":398,"children":399},{},[400,405,409],{"type":43,"tag":111,"props":401,"children":402},{},[403],{"type":49,"value":404},"\"My recent orders\" after placing one",{"type":43,"tag":111,"props":406,"children":407},{},[408],{"type":49,"value":321},{"type":43,"tag":111,"props":410,"children":411},{},[412],{"type":49,"value":413},"Primary or optimistic UI",{"type":43,"tag":64,"props":415,"children":417},{"id":416},"patterns",[418],{"type":49,"value":419},"Patterns",{"type":43,"tag":421,"props":422,"children":424},"h3",{"id":423},"return-the-written-data-simplest-best",[425],{"type":49,"value":426},"Return the written data (simplest, best)",{"type":43,"tag":428,"props":429,"children":434},"pre",{"className":430,"code":431,"language":432,"meta":433,"style":433},"language-typescript shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","app.post(\"\u002Fapi\u002Fprofile\", async (req, res) => {\n  const updated = await db.user.update({\n    where: { id: req.user.id },\n    data: { name: req.body.name, bio: req.body.bio },\n  });\n  res.json(updated); \u002F\u002F Return what we wrote. No second read needed.\n});\n","typescript","",[435],{"type":43,"tag":239,"props":436,"children":437},{"__ignoreMap":433},[438,527,585,639,725,743,785],{"type":43,"tag":439,"props":440,"children":442},"span",{"class":441,"line":30},"line",[443,449,455,461,466,471,477,481,486,492,497,503,507,512,517,522],{"type":43,"tag":439,"props":444,"children":446},{"style":445},"--shiki-light:#90A4AE;--shiki-default:#EEFFFF;--shiki-dark:#BABED8",[447],{"type":49,"value":448},"app",{"type":43,"tag":439,"props":450,"children":452},{"style":451},"--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF",[453],{"type":49,"value":454},".",{"type":43,"tag":439,"props":456,"children":458},{"style":457},"--shiki-light:#6182B8;--shiki-default:#82AAFF;--shiki-dark:#82AAFF",[459],{"type":49,"value":460},"post",{"type":43,"tag":439,"props":462,"children":463},{"style":445},[464],{"type":49,"value":465},"(",{"type":43,"tag":439,"props":467,"children":468},{"style":451},[469],{"type":49,"value":470},"\"",{"type":43,"tag":439,"props":472,"children":474},{"style":473},"--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D",[475],{"type":49,"value":476},"\u002Fapi\u002Fprofile",{"type":43,"tag":439,"props":478,"children":479},{"style":451},[480],{"type":49,"value":470},{"type":43,"tag":439,"props":482,"children":483},{"style":451},[484],{"type":49,"value":485},",",{"type":43,"tag":439,"props":487,"children":489},{"style":488},"--shiki-light:#9C3EDA;--shiki-default:#C792EA;--shiki-dark:#C792EA",[490],{"type":49,"value":491}," async",{"type":43,"tag":439,"props":493,"children":494},{"style":451},[495],{"type":49,"value":496}," (",{"type":43,"tag":439,"props":498,"children":500},{"style":499},"--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#EEFFFF;--shiki-default-font-style:italic;--shiki-dark:#BABED8;--shiki-dark-font-style:italic",[501],{"type":49,"value":502},"req",{"type":43,"tag":439,"props":504,"children":505},{"style":451},[506],{"type":49,"value":485},{"type":43,"tag":439,"props":508,"children":509},{"style":499},[510],{"type":49,"value":511}," res",{"type":43,"tag":439,"props":513,"children":514},{"style":451},[515],{"type":49,"value":516},")",{"type":43,"tag":439,"props":518,"children":519},{"style":488},[520],{"type":49,"value":521}," =>",{"type":43,"tag":439,"props":523,"children":524},{"style":451},[525],{"type":49,"value":526}," {\n",{"type":43,"tag":439,"props":528,"children":530},{"class":441,"line":529},2,[531,536,541,546,552,557,561,566,570,575,580],{"type":43,"tag":439,"props":532,"children":533},{"style":488},[534],{"type":49,"value":535},"  const",{"type":43,"tag":439,"props":537,"children":538},{"style":445},[539],{"type":49,"value":540}," updated",{"type":43,"tag":439,"props":542,"children":543},{"style":451},[544],{"type":49,"value":545}," =",{"type":43,"tag":439,"props":547,"children":549},{"style":548},"--shiki-light:#39ADB5;--shiki-light-font-style:italic;--shiki-default:#89DDFF;--shiki-default-font-style:italic;--shiki-dark:#89DDFF;--shiki-dark-font-style:italic",[550],{"type":49,"value":551}," await",{"type":43,"tag":439,"props":553,"children":554},{"style":445},[555],{"type":49,"value":556}," db",{"type":43,"tag":439,"props":558,"children":559},{"style":451},[560],{"type":49,"value":454},{"type":43,"tag":439,"props":562,"children":563},{"style":445},[564],{"type":49,"value":565},"user",{"type":43,"tag":439,"props":567,"children":568},{"style":451},[569],{"type":49,"value":454},{"type":43,"tag":439,"props":571,"children":572},{"style":457},[573],{"type":49,"value":574},"update",{"type":43,"tag":439,"props":576,"children":578},{"style":577},"--shiki-light:#E53935;--shiki-default:#F07178;--shiki-dark:#F07178",[579],{"type":49,"value":465},{"type":43,"tag":439,"props":581,"children":582},{"style":451},[583],{"type":49,"value":584},"{\n",{"type":43,"tag":439,"props":586,"children":587},{"class":441,"line":26},[588,593,598,603,608,612,617,621,625,629,634],{"type":43,"tag":439,"props":589,"children":590},{"style":577},[591],{"type":49,"value":592},"    where",{"type":43,"tag":439,"props":594,"children":595},{"style":451},[596],{"type":49,"value":597},":",{"type":43,"tag":439,"props":599,"children":600},{"style":451},[601],{"type":49,"value":602}," {",{"type":43,"tag":439,"props":604,"children":605},{"style":577},[606],{"type":49,"value":607}," id",{"type":43,"tag":439,"props":609,"children":610},{"style":451},[611],{"type":49,"value":597},{"type":43,"tag":439,"props":613,"children":614},{"style":445},[615],{"type":49,"value":616}," req",{"type":43,"tag":439,"props":618,"children":619},{"style":451},[620],{"type":49,"value":454},{"type":43,"tag":439,"props":622,"children":623},{"style":445},[624],{"type":49,"value":565},{"type":43,"tag":439,"props":626,"children":627},{"style":451},[628],{"type":49,"value":454},{"type":43,"tag":439,"props":630,"children":631},{"style":445},[632],{"type":49,"value":633},"id",{"type":43,"tag":439,"props":635,"children":636},{"style":451},[637],{"type":49,"value":638}," },\n",{"type":43,"tag":439,"props":640,"children":642},{"class":441,"line":641},4,[643,648,652,656,661,665,669,673,678,682,687,691,696,700,704,708,712,716,721],{"type":43,"tag":439,"props":644,"children":645},{"style":577},[646],{"type":49,"value":647},"    data",{"type":43,"tag":439,"props":649,"children":650},{"style":451},[651],{"type":49,"value":597},{"type":43,"tag":439,"props":653,"children":654},{"style":451},[655],{"type":49,"value":602},{"type":43,"tag":439,"props":657,"children":658},{"style":577},[659],{"type":49,"value":660}," name",{"type":43,"tag":439,"props":662,"children":663},{"style":451},[664],{"type":49,"value":597},{"type":43,"tag":439,"props":666,"children":667},{"style":445},[668],{"type":49,"value":616},{"type":43,"tag":439,"props":670,"children":671},{"style":451},[672],{"type":49,"value":454},{"type":43,"tag":439,"props":674,"children":675},{"style":445},[676],{"type":49,"value":677},"body",{"type":43,"tag":439,"props":679,"children":680},{"style":451},[681],{"type":49,"value":454},{"type":43,"tag":439,"props":683,"children":684},{"style":445},[685],{"type":49,"value":686},"name",{"type":43,"tag":439,"props":688,"children":689},{"style":451},[690],{"type":49,"value":485},{"type":43,"tag":439,"props":692,"children":693},{"style":577},[694],{"type":49,"value":695}," bio",{"type":43,"tag":439,"props":697,"children":698},{"style":451},[699],{"type":49,"value":597},{"type":43,"tag":439,"props":701,"children":702},{"style":445},[703],{"type":49,"value":616},{"type":43,"tag":439,"props":705,"children":706},{"style":451},[707],{"type":49,"value":454},{"type":43,"tag":439,"props":709,"children":710},{"style":445},[711],{"type":49,"value":677},{"type":43,"tag":439,"props":713,"children":714},{"style":451},[715],{"type":49,"value":454},{"type":43,"tag":439,"props":717,"children":718},{"style":445},[719],{"type":49,"value":720},"bio",{"type":43,"tag":439,"props":722,"children":723},{"style":451},[724],{"type":49,"value":638},{"type":43,"tag":439,"props":726,"children":728},{"class":441,"line":727},5,[729,734,738],{"type":43,"tag":439,"props":730,"children":731},{"style":451},[732],{"type":49,"value":733},"  }",{"type":43,"tag":439,"props":735,"children":736},{"style":577},[737],{"type":49,"value":516},{"type":43,"tag":439,"props":739,"children":740},{"style":451},[741],{"type":49,"value":742},";\n",{"type":43,"tag":439,"props":744,"children":746},{"class":441,"line":745},6,[747,752,756,761,765,770,774,779],{"type":43,"tag":439,"props":748,"children":749},{"style":445},[750],{"type":49,"value":751},"  res",{"type":43,"tag":439,"props":753,"children":754},{"style":451},[755],{"type":49,"value":454},{"type":43,"tag":439,"props":757,"children":758},{"style":457},[759],{"type":49,"value":760},"json",{"type":43,"tag":439,"props":762,"children":763},{"style":577},[764],{"type":49,"value":465},{"type":43,"tag":439,"props":766,"children":767},{"style":445},[768],{"type":49,"value":769},"updated",{"type":43,"tag":439,"props":771,"children":772},{"style":577},[773],{"type":49,"value":516},{"type":43,"tag":439,"props":775,"children":776},{"style":451},[777],{"type":49,"value":778},";",{"type":43,"tag":439,"props":780,"children":782},{"style":781},"--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#546E7A;--shiki-default-font-style:italic;--shiki-dark:#676E95;--shiki-dark-font-style:italic",[783],{"type":49,"value":784}," \u002F\u002F Return what we wrote. No second read needed.\n",{"type":43,"tag":439,"props":786,"children":788},{"class":441,"line":787},7,[789,794,798],{"type":43,"tag":439,"props":790,"children":791},{"style":451},[792],{"type":49,"value":793},"}",{"type":43,"tag":439,"props":795,"children":796},{"style":445},[797],{"type":49,"value":516},{"type":43,"tag":439,"props":799,"children":800},{"style":451},[801],{"type":49,"value":742},{"type":43,"tag":52,"props":803,"children":804},{},[805],{"type":49,"value":806},"No read-after-write means no consistency problem. Best pattern whenever the API can return the mutated entity.",{"type":43,"tag":421,"props":808,"children":810},{"id":809},"optimistic-ui-client-side",[811],{"type":49,"value":812},"Optimistic UI (client-side)",{"type":43,"tag":428,"props":814,"children":816},{"className":430,"code":815,"language":432,"meta":433,"style":433},"async function updateProfile(data: ProfileUpdate) {\n  setLocalProfile(prev => ({ ...prev, ...data })); \u002F\u002F Show immediately\n\n  const response = await fetch(\"\u002Fapi\u002Fprofile\", {\n    method: \"PUT\",\n    body: JSON.stringify(data),\n  });\n\n  if (!response.ok) {\n    setLocalProfile(previousProfile); \u002F\u002F Revert on failure\n    showError(\"Failed to save\");\n  }\n  \u002F\u002F Don't re-fetch. Trust local state. Others see it when read models catch up.\n}\n",[817],{"type":43,"tag":239,"props":818,"children":819},{"__ignoreMap":433},[820,865,935,944,993,1024,1066,1081,1089,1130,1161,1195,1204,1213],{"type":43,"tag":439,"props":821,"children":822},{"class":441,"line":30},[823,828,833,838,842,847,851,857,861],{"type":43,"tag":439,"props":824,"children":825},{"style":488},[826],{"type":49,"value":827},"async",{"type":43,"tag":439,"props":829,"children":830},{"style":488},[831],{"type":49,"value":832}," function",{"type":43,"tag":439,"props":834,"children":835},{"style":457},[836],{"type":49,"value":837}," updateProfile",{"type":43,"tag":439,"props":839,"children":840},{"style":451},[841],{"type":49,"value":465},{"type":43,"tag":439,"props":843,"children":844},{"style":499},[845],{"type":49,"value":846},"data",{"type":43,"tag":439,"props":848,"children":849},{"style":451},[850],{"type":49,"value":597},{"type":43,"tag":439,"props":852,"children":854},{"style":853},"--shiki-light:#E2931D;--shiki-default:#FFCB6B;--shiki-dark:#FFCB6B",[855],{"type":49,"value":856}," ProfileUpdate",{"type":43,"tag":439,"props":858,"children":859},{"style":451},[860],{"type":49,"value":516},{"type":43,"tag":439,"props":862,"children":863},{"style":451},[864],{"type":49,"value":526},{"type":43,"tag":439,"props":866,"children":867},{"class":441,"line":529},[868,873,877,882,886,890,895,900,904,908,912,916,921,926,930],{"type":43,"tag":439,"props":869,"children":870},{"style":457},[871],{"type":49,"value":872},"  setLocalProfile",{"type":43,"tag":439,"props":874,"children":875},{"style":577},[876],{"type":49,"value":465},{"type":43,"tag":439,"props":878,"children":879},{"style":499},[880],{"type":49,"value":881},"prev",{"type":43,"tag":439,"props":883,"children":884},{"style":488},[885],{"type":49,"value":521},{"type":43,"tag":439,"props":887,"children":888},{"style":577},[889],{"type":49,"value":496},{"type":43,"tag":439,"props":891,"children":892},{"style":451},[893],{"type":49,"value":894},"{",{"type":43,"tag":439,"props":896,"children":897},{"style":451},[898],{"type":49,"value":899}," ...",{"type":43,"tag":439,"props":901,"children":902},{"style":445},[903],{"type":49,"value":881},{"type":43,"tag":439,"props":905,"children":906},{"style":451},[907],{"type":49,"value":485},{"type":43,"tag":439,"props":909,"children":910},{"style":451},[911],{"type":49,"value":899},{"type":43,"tag":439,"props":913,"children":914},{"style":445},[915],{"type":49,"value":846},{"type":43,"tag":439,"props":917,"children":918},{"style":451},[919],{"type":49,"value":920}," }",{"type":43,"tag":439,"props":922,"children":923},{"style":577},[924],{"type":49,"value":925},"))",{"type":43,"tag":439,"props":927,"children":928},{"style":451},[929],{"type":49,"value":778},{"type":43,"tag":439,"props":931,"children":932},{"style":781},[933],{"type":49,"value":934}," \u002F\u002F Show immediately\n",{"type":43,"tag":439,"props":936,"children":937},{"class":441,"line":26},[938],{"type":43,"tag":439,"props":939,"children":941},{"emptyLinePlaceholder":940},true,[942],{"type":49,"value":943},"\n",{"type":43,"tag":439,"props":945,"children":946},{"class":441,"line":641},[947,951,956,960,964,969,973,977,981,985,989],{"type":43,"tag":439,"props":948,"children":949},{"style":488},[950],{"type":49,"value":535},{"type":43,"tag":439,"props":952,"children":953},{"style":445},[954],{"type":49,"value":955}," response",{"type":43,"tag":439,"props":957,"children":958},{"style":451},[959],{"type":49,"value":545},{"type":43,"tag":439,"props":961,"children":962},{"style":548},[963],{"type":49,"value":551},{"type":43,"tag":439,"props":965,"children":966},{"style":457},[967],{"type":49,"value":968}," fetch",{"type":43,"tag":439,"props":970,"children":971},{"style":577},[972],{"type":49,"value":465},{"type":43,"tag":439,"props":974,"children":975},{"style":451},[976],{"type":49,"value":470},{"type":43,"tag":439,"props":978,"children":979},{"style":473},[980],{"type":49,"value":476},{"type":43,"tag":439,"props":982,"children":983},{"style":451},[984],{"type":49,"value":470},{"type":43,"tag":439,"props":986,"children":987},{"style":451},[988],{"type":49,"value":485},{"type":43,"tag":439,"props":990,"children":991},{"style":451},[992],{"type":49,"value":526},{"type":43,"tag":439,"props":994,"children":995},{"class":441,"line":727},[996,1001,1005,1010,1015,1019],{"type":43,"tag":439,"props":997,"children":998},{"style":577},[999],{"type":49,"value":1000},"    method",{"type":43,"tag":439,"props":1002,"children":1003},{"style":451},[1004],{"type":49,"value":597},{"type":43,"tag":439,"props":1006,"children":1007},{"style":451},[1008],{"type":49,"value":1009}," \"",{"type":43,"tag":439,"props":1011,"children":1012},{"style":473},[1013],{"type":49,"value":1014},"PUT",{"type":43,"tag":439,"props":1016,"children":1017},{"style":451},[1018],{"type":49,"value":470},{"type":43,"tag":439,"props":1020,"children":1021},{"style":451},[1022],{"type":49,"value":1023},",\n",{"type":43,"tag":439,"props":1025,"children":1026},{"class":441,"line":745},[1027,1032,1036,1041,1045,1050,1054,1058,1062],{"type":43,"tag":439,"props":1028,"children":1029},{"style":577},[1030],{"type":49,"value":1031},"    body",{"type":43,"tag":439,"props":1033,"children":1034},{"style":451},[1035],{"type":49,"value":597},{"type":43,"tag":439,"props":1037,"children":1038},{"style":445},[1039],{"type":49,"value":1040}," JSON",{"type":43,"tag":439,"props":1042,"children":1043},{"style":451},[1044],{"type":49,"value":454},{"type":43,"tag":439,"props":1046,"children":1047},{"style":457},[1048],{"type":49,"value":1049},"stringify",{"type":43,"tag":439,"props":1051,"children":1052},{"style":577},[1053],{"type":49,"value":465},{"type":43,"tag":439,"props":1055,"children":1056},{"style":445},[1057],{"type":49,"value":846},{"type":43,"tag":439,"props":1059,"children":1060},{"style":577},[1061],{"type":49,"value":516},{"type":43,"tag":439,"props":1063,"children":1064},{"style":451},[1065],{"type":49,"value":1023},{"type":43,"tag":439,"props":1067,"children":1068},{"class":441,"line":787},[1069,1073,1077],{"type":43,"tag":439,"props":1070,"children":1071},{"style":451},[1072],{"type":49,"value":733},{"type":43,"tag":439,"props":1074,"children":1075},{"style":577},[1076],{"type":49,"value":516},{"type":43,"tag":439,"props":1078,"children":1079},{"style":451},[1080],{"type":49,"value":742},{"type":43,"tag":439,"props":1082,"children":1084},{"class":441,"line":1083},8,[1085],{"type":43,"tag":439,"props":1086,"children":1087},{"emptyLinePlaceholder":940},[1088],{"type":49,"value":943},{"type":43,"tag":439,"props":1090,"children":1092},{"class":441,"line":1091},9,[1093,1098,1102,1107,1112,1116,1121,1126],{"type":43,"tag":439,"props":1094,"children":1095},{"style":548},[1096],{"type":49,"value":1097},"  if",{"type":43,"tag":439,"props":1099,"children":1100},{"style":577},[1101],{"type":49,"value":496},{"type":43,"tag":439,"props":1103,"children":1104},{"style":451},[1105],{"type":49,"value":1106},"!",{"type":43,"tag":439,"props":1108,"children":1109},{"style":445},[1110],{"type":49,"value":1111},"response",{"type":43,"tag":439,"props":1113,"children":1114},{"style":451},[1115],{"type":49,"value":454},{"type":43,"tag":439,"props":1117,"children":1118},{"style":445},[1119],{"type":49,"value":1120},"ok",{"type":43,"tag":439,"props":1122,"children":1123},{"style":577},[1124],{"type":49,"value":1125},") ",{"type":43,"tag":439,"props":1127,"children":1128},{"style":451},[1129],{"type":49,"value":584},{"type":43,"tag":439,"props":1131,"children":1133},{"class":441,"line":1132},10,[1134,1139,1143,1148,1152,1156],{"type":43,"tag":439,"props":1135,"children":1136},{"style":457},[1137],{"type":49,"value":1138},"    setLocalProfile",{"type":43,"tag":439,"props":1140,"children":1141},{"style":577},[1142],{"type":49,"value":465},{"type":43,"tag":439,"props":1144,"children":1145},{"style":445},[1146],{"type":49,"value":1147},"previousProfile",{"type":43,"tag":439,"props":1149,"children":1150},{"style":577},[1151],{"type":49,"value":516},{"type":43,"tag":439,"props":1153,"children":1154},{"style":451},[1155],{"type":49,"value":778},{"type":43,"tag":439,"props":1157,"children":1158},{"style":781},[1159],{"type":49,"value":1160}," \u002F\u002F Revert on failure\n",{"type":43,"tag":439,"props":1162,"children":1164},{"class":441,"line":1163},11,[1165,1170,1174,1178,1183,1187,1191],{"type":43,"tag":439,"props":1166,"children":1167},{"style":457},[1168],{"type":49,"value":1169},"    showError",{"type":43,"tag":439,"props":1171,"children":1172},{"style":577},[1173],{"type":49,"value":465},{"type":43,"tag":439,"props":1175,"children":1176},{"style":451},[1177],{"type":49,"value":470},{"type":43,"tag":439,"props":1179,"children":1180},{"style":473},[1181],{"type":49,"value":1182},"Failed to save",{"type":43,"tag":439,"props":1184,"children":1185},{"style":451},[1186],{"type":49,"value":470},{"type":43,"tag":439,"props":1188,"children":1189},{"style":577},[1190],{"type":49,"value":516},{"type":43,"tag":439,"props":1192,"children":1193},{"style":451},[1194],{"type":49,"value":742},{"type":43,"tag":439,"props":1196,"children":1198},{"class":441,"line":1197},12,[1199],{"type":43,"tag":439,"props":1200,"children":1201},{"style":451},[1202],{"type":49,"value":1203},"  }\n",{"type":43,"tag":439,"props":1205,"children":1207},{"class":441,"line":1206},13,[1208],{"type":43,"tag":439,"props":1209,"children":1210},{"style":781},[1211],{"type":49,"value":1212},"  \u002F\u002F Don't re-fetch. Trust local state. Others see it when read models catch up.\n",{"type":43,"tag":439,"props":1214,"children":1216},{"class":441,"line":1215},14,[1217],{"type":43,"tag":439,"props":1218,"children":1219},{"style":451},[1220],{"type":49,"value":1221},"}\n",{"type":43,"tag":52,"props":1223,"children":1224},{},[1225],{"type":49,"value":1226},"The writer sees the change immediately -- no round-trip, no gap. Standard for modern SPAs.",{"type":43,"tag":421,"props":1228,"children":1230},{"id":1229},"read-from-primary-after-write",[1231],{"type":49,"value":1232},"Read from primary after write",{"type":43,"tag":428,"props":1234,"children":1236},{"className":430,"code":1235,"language":432,"meta":433,"style":433},"app.post(\"\u002Fapi\u002Fprofile\", async (req, res) => {\n  await db.user.update({ where: { id: req.user.id }, data: req.body });\n  res.cookie(\"_read_primary\", \"1\", { maxAge: 5000 }); \u002F\u002F tell read path to use primary\n  res.redirect(`\u002Fprofile\u002F${req.user.id}`);\n});\n\napp.get(\"\u002Fprofile\u002F:id\", async (req, res) => {\n  const forcePrimary = req.cookies._read_primary === \"1\";\n  const user = await db.user.findUnique({\n    where: { id: req.params.id },\n    ...(forcePrimary && { replicaRead: false }), \u002F\u002F framework-specific\n  });\n  res.render(\"profile\", { user });\n});\n",[1237],{"type":43,"tag":239,"props":1238,"children":1239},{"__ignoreMap":433},[1240,1307,1422,1512,1580,1595,1602,1671,1729,1778,1826,1884,1899,1956],{"type":43,"tag":439,"props":1241,"children":1242},{"class":441,"line":30},[1243,1247,1251,1255,1259,1263,1267,1271,1275,1279,1283,1287,1291,1295,1299,1303],{"type":43,"tag":439,"props":1244,"children":1245},{"style":445},[1246],{"type":49,"value":448},{"type":43,"tag":439,"props":1248,"children":1249},{"style":451},[1250],{"type":49,"value":454},{"type":43,"tag":439,"props":1252,"children":1253},{"style":457},[1254],{"type":49,"value":460},{"type":43,"tag":439,"props":1256,"children":1257},{"style":445},[1258],{"type":49,"value":465},{"type":43,"tag":439,"props":1260,"children":1261},{"style":451},[1262],{"type":49,"value":470},{"type":43,"tag":439,"props":1264,"children":1265},{"style":473},[1266],{"type":49,"value":476},{"type":43,"tag":439,"props":1268,"children":1269},{"style":451},[1270],{"type":49,"value":470},{"type":43,"tag":439,"props":1272,"children":1273},{"style":451},[1274],{"type":49,"value":485},{"type":43,"tag":439,"props":1276,"children":1277},{"style":488},[1278],{"type":49,"value":491},{"type":43,"tag":439,"props":1280,"children":1281},{"style":451},[1282],{"type":49,"value":496},{"type":43,"tag":439,"props":1284,"children":1285},{"style":499},[1286],{"type":49,"value":502},{"type":43,"tag":439,"props":1288,"children":1289},{"style":451},[1290],{"type":49,"value":485},{"type":43,"tag":439,"props":1292,"children":1293},{"style":499},[1294],{"type":49,"value":511},{"type":43,"tag":439,"props":1296,"children":1297},{"style":451},[1298],{"type":49,"value":516},{"type":43,"tag":439,"props":1300,"children":1301},{"style":488},[1302],{"type":49,"value":521},{"type":43,"tag":439,"props":1304,"children":1305},{"style":451},[1306],{"type":49,"value":526},{"type":43,"tag":439,"props":1308,"children":1309},{"class":441,"line":529},[1310,1315,1319,1323,1327,1331,1335,1339,1343,1348,1352,1356,1360,1364,1368,1372,1376,1380,1384,1389,1394,1398,1402,1406,1410,1414,1418],{"type":43,"tag":439,"props":1311,"children":1312},{"style":548},[1313],{"type":49,"value":1314},"  await",{"type":43,"tag":439,"props":1316,"children":1317},{"style":445},[1318],{"type":49,"value":556},{"type":43,"tag":439,"props":1320,"children":1321},{"style":451},[1322],{"type":49,"value":454},{"type":43,"tag":439,"props":1324,"children":1325},{"style":445},[1326],{"type":49,"value":565},{"type":43,"tag":439,"props":1328,"children":1329},{"style":451},[1330],{"type":49,"value":454},{"type":43,"tag":439,"props":1332,"children":1333},{"style":457},[1334],{"type":49,"value":574},{"type":43,"tag":439,"props":1336,"children":1337},{"style":577},[1338],{"type":49,"value":465},{"type":43,"tag":439,"props":1340,"children":1341},{"style":451},[1342],{"type":49,"value":894},{"type":43,"tag":439,"props":1344,"children":1345},{"style":577},[1346],{"type":49,"value":1347}," where",{"type":43,"tag":439,"props":1349,"children":1350},{"style":451},[1351],{"type":49,"value":597},{"type":43,"tag":439,"props":1353,"children":1354},{"style":451},[1355],{"type":49,"value":602},{"type":43,"tag":439,"props":1357,"children":1358},{"style":577},[1359],{"type":49,"value":607},{"type":43,"tag":439,"props":1361,"children":1362},{"style":451},[1363],{"type":49,"value":597},{"type":43,"tag":439,"props":1365,"children":1366},{"style":445},[1367],{"type":49,"value":616},{"type":43,"tag":439,"props":1369,"children":1370},{"style":451},[1371],{"type":49,"value":454},{"type":43,"tag":439,"props":1373,"children":1374},{"style":445},[1375],{"type":49,"value":565},{"type":43,"tag":439,"props":1377,"children":1378},{"style":451},[1379],{"type":49,"value":454},{"type":43,"tag":439,"props":1381,"children":1382},{"style":445},[1383],{"type":49,"value":633},{"type":43,"tag":439,"props":1385,"children":1386},{"style":451},[1387],{"type":49,"value":1388}," },",{"type":43,"tag":439,"props":1390,"children":1391},{"style":577},[1392],{"type":49,"value":1393}," data",{"type":43,"tag":439,"props":1395,"children":1396},{"style":451},[1397],{"type":49,"value":597},{"type":43,"tag":439,"props":1399,"children":1400},{"style":445},[1401],{"type":49,"value":616},{"type":43,"tag":439,"props":1403,"children":1404},{"style":451},[1405],{"type":49,"value":454},{"type":43,"tag":439,"props":1407,"children":1408},{"style":445},[1409],{"type":49,"value":677},{"type":43,"tag":439,"props":1411,"children":1412},{"style":451},[1413],{"type":49,"value":920},{"type":43,"tag":439,"props":1415,"children":1416},{"style":577},[1417],{"type":49,"value":516},{"type":43,"tag":439,"props":1419,"children":1420},{"style":451},[1421],{"type":49,"value":742},{"type":43,"tag":439,"props":1423,"children":1424},{"class":441,"line":26},[1425,1429,1433,1438,1442,1446,1451,1455,1459,1463,1468,1472,1476,1480,1485,1489,1495,1499,1503,1507],{"type":43,"tag":439,"props":1426,"children":1427},{"style":445},[1428],{"type":49,"value":751},{"type":43,"tag":439,"props":1430,"children":1431},{"style":451},[1432],{"type":49,"value":454},{"type":43,"tag":439,"props":1434,"children":1435},{"style":457},[1436],{"type":49,"value":1437},"cookie",{"type":43,"tag":439,"props":1439,"children":1440},{"style":577},[1441],{"type":49,"value":465},{"type":43,"tag":439,"props":1443,"children":1444},{"style":451},[1445],{"type":49,"value":470},{"type":43,"tag":439,"props":1447,"children":1448},{"style":473},[1449],{"type":49,"value":1450},"_read_primary",{"type":43,"tag":439,"props":1452,"children":1453},{"style":451},[1454],{"type":49,"value":470},{"type":43,"tag":439,"props":1456,"children":1457},{"style":451},[1458],{"type":49,"value":485},{"type":43,"tag":439,"props":1460,"children":1461},{"style":451},[1462],{"type":49,"value":1009},{"type":43,"tag":439,"props":1464,"children":1465},{"style":473},[1466],{"type":49,"value":1467},"1",{"type":43,"tag":439,"props":1469,"children":1470},{"style":451},[1471],{"type":49,"value":470},{"type":43,"tag":439,"props":1473,"children":1474},{"style":451},[1475],{"type":49,"value":485},{"type":43,"tag":439,"props":1477,"children":1478},{"style":451},[1479],{"type":49,"value":602},{"type":43,"tag":439,"props":1481,"children":1482},{"style":577},[1483],{"type":49,"value":1484}," maxAge",{"type":43,"tag":439,"props":1486,"children":1487},{"style":451},[1488],{"type":49,"value":597},{"type":43,"tag":439,"props":1490,"children":1492},{"style":1491},"--shiki-light:#F76D47;--shiki-default:#F78C6C;--shiki-dark:#F78C6C",[1493],{"type":49,"value":1494}," 5000",{"type":43,"tag":439,"props":1496,"children":1497},{"style":451},[1498],{"type":49,"value":920},{"type":43,"tag":439,"props":1500,"children":1501},{"style":577},[1502],{"type":49,"value":516},{"type":43,"tag":439,"props":1504,"children":1505},{"style":451},[1506],{"type":49,"value":778},{"type":43,"tag":439,"props":1508,"children":1509},{"style":781},[1510],{"type":49,"value":1511}," \u002F\u002F tell read path to use primary\n",{"type":43,"tag":439,"props":1513,"children":1514},{"class":441,"line":641},[1515,1519,1523,1528,1532,1537,1542,1547,1551,1555,1559,1563,1567,1572,1576],{"type":43,"tag":439,"props":1516,"children":1517},{"style":445},[1518],{"type":49,"value":751},{"type":43,"tag":439,"props":1520,"children":1521},{"style":451},[1522],{"type":49,"value":454},{"type":43,"tag":439,"props":1524,"children":1525},{"style":457},[1526],{"type":49,"value":1527},"redirect",{"type":43,"tag":439,"props":1529,"children":1530},{"style":577},[1531],{"type":49,"value":465},{"type":43,"tag":439,"props":1533,"children":1534},{"style":451},[1535],{"type":49,"value":1536},"`",{"type":43,"tag":439,"props":1538,"children":1539},{"style":473},[1540],{"type":49,"value":1541},"\u002Fprofile\u002F",{"type":43,"tag":439,"props":1543,"children":1544},{"style":451},[1545],{"type":49,"value":1546},"${",{"type":43,"tag":439,"props":1548,"children":1549},{"style":445},[1550],{"type":49,"value":502},{"type":43,"tag":439,"props":1552,"children":1553},{"style":451},[1554],{"type":49,"value":454},{"type":43,"tag":439,"props":1556,"children":1557},{"style":445},[1558],{"type":49,"value":565},{"type":43,"tag":439,"props":1560,"children":1561},{"style":451},[1562],{"type":49,"value":454},{"type":43,"tag":439,"props":1564,"children":1565},{"style":445},[1566],{"type":49,"value":633},{"type":43,"tag":439,"props":1568,"children":1569},{"style":451},[1570],{"type":49,"value":1571},"}`",{"type":43,"tag":439,"props":1573,"children":1574},{"style":577},[1575],{"type":49,"value":516},{"type":43,"tag":439,"props":1577,"children":1578},{"style":451},[1579],{"type":49,"value":742},{"type":43,"tag":439,"props":1581,"children":1582},{"class":441,"line":727},[1583,1587,1591],{"type":43,"tag":439,"props":1584,"children":1585},{"style":451},[1586],{"type":49,"value":793},{"type":43,"tag":439,"props":1588,"children":1589},{"style":445},[1590],{"type":49,"value":516},{"type":43,"tag":439,"props":1592,"children":1593},{"style":451},[1594],{"type":49,"value":742},{"type":43,"tag":439,"props":1596,"children":1597},{"class":441,"line":745},[1598],{"type":43,"tag":439,"props":1599,"children":1600},{"emptyLinePlaceholder":940},[1601],{"type":49,"value":943},{"type":43,"tag":439,"props":1603,"children":1604},{"class":441,"line":787},[1605,1609,1613,1618,1622,1626,1631,1635,1639,1643,1647,1651,1655,1659,1663,1667],{"type":43,"tag":439,"props":1606,"children":1607},{"style":445},[1608],{"type":49,"value":448},{"type":43,"tag":439,"props":1610,"children":1611},{"style":451},[1612],{"type":49,"value":454},{"type":43,"tag":439,"props":1614,"children":1615},{"style":457},[1616],{"type":49,"value":1617},"get",{"type":43,"tag":439,"props":1619,"children":1620},{"style":445},[1621],{"type":49,"value":465},{"type":43,"tag":439,"props":1623,"children":1624},{"style":451},[1625],{"type":49,"value":470},{"type":43,"tag":439,"props":1627,"children":1628},{"style":473},[1629],{"type":49,"value":1630},"\u002Fprofile\u002F:id",{"type":43,"tag":439,"props":1632,"children":1633},{"style":451},[1634],{"type":49,"value":470},{"type":43,"tag":439,"props":1636,"children":1637},{"style":451},[1638],{"type":49,"value":485},{"type":43,"tag":439,"props":1640,"children":1641},{"style":488},[1642],{"type":49,"value":491},{"type":43,"tag":439,"props":1644,"children":1645},{"style":451},[1646],{"type":49,"value":496},{"type":43,"tag":439,"props":1648,"children":1649},{"style":499},[1650],{"type":49,"value":502},{"type":43,"tag":439,"props":1652,"children":1653},{"style":451},[1654],{"type":49,"value":485},{"type":43,"tag":439,"props":1656,"children":1657},{"style":499},[1658],{"type":49,"value":511},{"type":43,"tag":439,"props":1660,"children":1661},{"style":451},[1662],{"type":49,"value":516},{"type":43,"tag":439,"props":1664,"children":1665},{"style":488},[1666],{"type":49,"value":521},{"type":43,"tag":439,"props":1668,"children":1669},{"style":451},[1670],{"type":49,"value":526},{"type":43,"tag":439,"props":1672,"children":1673},{"class":441,"line":1083},[1674,1678,1683,1687,1691,1695,1700,1704,1708,1713,1717,1721,1725],{"type":43,"tag":439,"props":1675,"children":1676},{"style":488},[1677],{"type":49,"value":535},{"type":43,"tag":439,"props":1679,"children":1680},{"style":445},[1681],{"type":49,"value":1682}," forcePrimary",{"type":43,"tag":439,"props":1684,"children":1685},{"style":451},[1686],{"type":49,"value":545},{"type":43,"tag":439,"props":1688,"children":1689},{"style":445},[1690],{"type":49,"value":616},{"type":43,"tag":439,"props":1692,"children":1693},{"style":451},[1694],{"type":49,"value":454},{"type":43,"tag":439,"props":1696,"children":1697},{"style":445},[1698],{"type":49,"value":1699},"cookies",{"type":43,"tag":439,"props":1701,"children":1702},{"style":451},[1703],{"type":49,"value":454},{"type":43,"tag":439,"props":1705,"children":1706},{"style":445},[1707],{"type":49,"value":1450},{"type":43,"tag":439,"props":1709,"children":1710},{"style":451},[1711],{"type":49,"value":1712}," ===",{"type":43,"tag":439,"props":1714,"children":1715},{"style":451},[1716],{"type":49,"value":1009},{"type":43,"tag":439,"props":1718,"children":1719},{"style":473},[1720],{"type":49,"value":1467},{"type":43,"tag":439,"props":1722,"children":1723},{"style":451},[1724],{"type":49,"value":470},{"type":43,"tag":439,"props":1726,"children":1727},{"style":451},[1728],{"type":49,"value":742},{"type":43,"tag":439,"props":1730,"children":1731},{"class":441,"line":1091},[1732,1736,1741,1745,1749,1753,1757,1761,1765,1770,1774],{"type":43,"tag":439,"props":1733,"children":1734},{"style":488},[1735],{"type":49,"value":535},{"type":43,"tag":439,"props":1737,"children":1738},{"style":445},[1739],{"type":49,"value":1740}," user",{"type":43,"tag":439,"props":1742,"children":1743},{"style":451},[1744],{"type":49,"value":545},{"type":43,"tag":439,"props":1746,"children":1747},{"style":548},[1748],{"type":49,"value":551},{"type":43,"tag":439,"props":1750,"children":1751},{"style":445},[1752],{"type":49,"value":556},{"type":43,"tag":439,"props":1754,"children":1755},{"style":451},[1756],{"type":49,"value":454},{"type":43,"tag":439,"props":1758,"children":1759},{"style":445},[1760],{"type":49,"value":565},{"type":43,"tag":439,"props":1762,"children":1763},{"style":451},[1764],{"type":49,"value":454},{"type":43,"tag":439,"props":1766,"children":1767},{"style":457},[1768],{"type":49,"value":1769},"findUnique",{"type":43,"tag":439,"props":1771,"children":1772},{"style":577},[1773],{"type":49,"value":465},{"type":43,"tag":439,"props":1775,"children":1776},{"style":451},[1777],{"type":49,"value":584},{"type":43,"tag":439,"props":1779,"children":1780},{"class":441,"line":1132},[1781,1785,1789,1793,1797,1801,1805,1809,1814,1818,1822],{"type":43,"tag":439,"props":1782,"children":1783},{"style":577},[1784],{"type":49,"value":592},{"type":43,"tag":439,"props":1786,"children":1787},{"style":451},[1788],{"type":49,"value":597},{"type":43,"tag":439,"props":1790,"children":1791},{"style":451},[1792],{"type":49,"value":602},{"type":43,"tag":439,"props":1794,"children":1795},{"style":577},[1796],{"type":49,"value":607},{"type":43,"tag":439,"props":1798,"children":1799},{"style":451},[1800],{"type":49,"value":597},{"type":43,"tag":439,"props":1802,"children":1803},{"style":445},[1804],{"type":49,"value":616},{"type":43,"tag":439,"props":1806,"children":1807},{"style":451},[1808],{"type":49,"value":454},{"type":43,"tag":439,"props":1810,"children":1811},{"style":445},[1812],{"type":49,"value":1813},"params",{"type":43,"tag":439,"props":1815,"children":1816},{"style":451},[1817],{"type":49,"value":454},{"type":43,"tag":439,"props":1819,"children":1820},{"style":445},[1821],{"type":49,"value":633},{"type":43,"tag":439,"props":1823,"children":1824},{"style":451},[1825],{"type":49,"value":638},{"type":43,"tag":439,"props":1827,"children":1828},{"class":441,"line":1163},[1829,1834,1838,1843,1848,1852,1857,1861,1867,1871,1875,1879],{"type":43,"tag":439,"props":1830,"children":1831},{"style":451},[1832],{"type":49,"value":1833},"    ...",{"type":43,"tag":439,"props":1835,"children":1836},{"style":577},[1837],{"type":49,"value":465},{"type":43,"tag":439,"props":1839,"children":1840},{"style":445},[1841],{"type":49,"value":1842},"forcePrimary",{"type":43,"tag":439,"props":1844,"children":1845},{"style":451},[1846],{"type":49,"value":1847}," &&",{"type":43,"tag":439,"props":1849,"children":1850},{"style":451},[1851],{"type":49,"value":602},{"type":43,"tag":439,"props":1853,"children":1854},{"style":577},[1855],{"type":49,"value":1856}," replicaRead",{"type":43,"tag":439,"props":1858,"children":1859},{"style":451},[1860],{"type":49,"value":597},{"type":43,"tag":439,"props":1862,"children":1864},{"style":1863},"--shiki-light:#FF5370;--shiki-default:#FF9CAC;--shiki-dark:#FF9CAC",[1865],{"type":49,"value":1866}," false",{"type":43,"tag":439,"props":1868,"children":1869},{"style":451},[1870],{"type":49,"value":920},{"type":43,"tag":439,"props":1872,"children":1873},{"style":577},[1874],{"type":49,"value":516},{"type":43,"tag":439,"props":1876,"children":1877},{"style":451},[1878],{"type":49,"value":485},{"type":43,"tag":439,"props":1880,"children":1881},{"style":781},[1882],{"type":49,"value":1883}," \u002F\u002F framework-specific\n",{"type":43,"tag":439,"props":1885,"children":1886},{"class":441,"line":1197},[1887,1891,1895],{"type":43,"tag":439,"props":1888,"children":1889},{"style":451},[1890],{"type":49,"value":733},{"type":43,"tag":439,"props":1892,"children":1893},{"style":577},[1894],{"type":49,"value":516},{"type":43,"tag":439,"props":1896,"children":1897},{"style":451},[1898],{"type":49,"value":742},{"type":43,"tag":439,"props":1900,"children":1901},{"class":441,"line":1206},[1902,1906,1910,1915,1919,1923,1928,1932,1936,1940,1944,1948,1952],{"type":43,"tag":439,"props":1903,"children":1904},{"style":445},[1905],{"type":49,"value":751},{"type":43,"tag":439,"props":1907,"children":1908},{"style":451},[1909],{"type":49,"value":454},{"type":43,"tag":439,"props":1911,"children":1912},{"style":457},[1913],{"type":49,"value":1914},"render",{"type":43,"tag":439,"props":1916,"children":1917},{"style":577},[1918],{"type":49,"value":465},{"type":43,"tag":439,"props":1920,"children":1921},{"style":451},[1922],{"type":49,"value":470},{"type":43,"tag":439,"props":1924,"children":1925},{"style":473},[1926],{"type":49,"value":1927},"profile",{"type":43,"tag":439,"props":1929,"children":1930},{"style":451},[1931],{"type":49,"value":470},{"type":43,"tag":439,"props":1933,"children":1934},{"style":451},[1935],{"type":49,"value":485},{"type":43,"tag":439,"props":1937,"children":1938},{"style":451},[1939],{"type":49,"value":602},{"type":43,"tag":439,"props":1941,"children":1942},{"style":445},[1943],{"type":49,"value":1740},{"type":43,"tag":439,"props":1945,"children":1946},{"style":451},[1947],{"type":49,"value":920},{"type":43,"tag":439,"props":1949,"children":1950},{"style":577},[1951],{"type":49,"value":516},{"type":43,"tag":439,"props":1953,"children":1954},{"style":451},[1955],{"type":49,"value":742},{"type":43,"tag":439,"props":1957,"children":1958},{"class":441,"line":1215},[1959,1963,1967],{"type":43,"tag":439,"props":1960,"children":1961},{"style":451},[1962],{"type":49,"value":793},{"type":43,"tag":439,"props":1964,"children":1965},{"style":445},[1966],{"type":49,"value":516},{"type":43,"tag":439,"props":1968,"children":1969},{"style":451},[1970],{"type":49,"value":742},{"type":43,"tag":52,"props":1972,"children":1973},{},[1974],{"type":49,"value":1975},"Only the user who wrote gets the primary read; once the cookie expires, reads return to replicas. Everyone else stays on replicas throughout.",{"type":43,"tag":421,"props":1977,"children":1979},{"id":1978},"write-through-cache",[1980],{"type":49,"value":1981},"Write-through cache",{"type":43,"tag":428,"props":1983,"children":1985},{"className":430,"code":1984,"language":432,"meta":433,"style":433},"async function updateUser(userId: string, data: Partial\u003CUser>) {\n  const updated = await db.user.update({ where: { id: userId }, data });\n  \u002F\u002F Set cache to the known-correct value, don't just delete it.\n  await redis.set(`user:${userId}`, JSON.stringify(updated), \"EX\", 300);\n  return updated;\n}\n",[1986],{"type":43,"tag":239,"props":1987,"children":1988},{"__ignoreMap":433},[1989,2059,2151,2159,2267,2283],{"type":43,"tag":439,"props":1990,"children":1991},{"class":441,"line":30},[1992,1996,2000,2005,2009,2014,2018,2023,2027,2031,2035,2040,2045,2050,2055],{"type":43,"tag":439,"props":1993,"children":1994},{"style":488},[1995],{"type":49,"value":827},{"type":43,"tag":439,"props":1997,"children":1998},{"style":488},[1999],{"type":49,"value":832},{"type":43,"tag":439,"props":2001,"children":2002},{"style":457},[2003],{"type":49,"value":2004}," updateUser",{"type":43,"tag":439,"props":2006,"children":2007},{"style":451},[2008],{"type":49,"value":465},{"type":43,"tag":439,"props":2010,"children":2011},{"style":499},[2012],{"type":49,"value":2013},"userId",{"type":43,"tag":439,"props":2015,"children":2016},{"style":451},[2017],{"type":49,"value":597},{"type":43,"tag":439,"props":2019,"children":2020},{"style":853},[2021],{"type":49,"value":2022}," string",{"type":43,"tag":439,"props":2024,"children":2025},{"style":451},[2026],{"type":49,"value":485},{"type":43,"tag":439,"props":2028,"children":2029},{"style":499},[2030],{"type":49,"value":1393},{"type":43,"tag":439,"props":2032,"children":2033},{"style":451},[2034],{"type":49,"value":597},{"type":43,"tag":439,"props":2036,"children":2037},{"style":853},[2038],{"type":49,"value":2039}," Partial",{"type":43,"tag":439,"props":2041,"children":2042},{"style":451},[2043],{"type":49,"value":2044},"\u003C",{"type":43,"tag":439,"props":2046,"children":2047},{"style":853},[2048],{"type":49,"value":2049},"User",{"type":43,"tag":439,"props":2051,"children":2052},{"style":451},[2053],{"type":49,"value":2054},">)",{"type":43,"tag":439,"props":2056,"children":2057},{"style":451},[2058],{"type":49,"value":526},{"type":43,"tag":439,"props":2060,"children":2061},{"class":441,"line":529},[2062,2066,2070,2074,2078,2082,2086,2090,2094,2098,2102,2106,2110,2114,2118,2122,2126,2131,2135,2139,2143,2147],{"type":43,"tag":439,"props":2063,"children":2064},{"style":488},[2065],{"type":49,"value":535},{"type":43,"tag":439,"props":2067,"children":2068},{"style":445},[2069],{"type":49,"value":540},{"type":43,"tag":439,"props":2071,"children":2072},{"style":451},[2073],{"type":49,"value":545},{"type":43,"tag":439,"props":2075,"children":2076},{"style":548},[2077],{"type":49,"value":551},{"type":43,"tag":439,"props":2079,"children":2080},{"style":445},[2081],{"type":49,"value":556},{"type":43,"tag":439,"props":2083,"children":2084},{"style":451},[2085],{"type":49,"value":454},{"type":43,"tag":439,"props":2087,"children":2088},{"style":445},[2089],{"type":49,"value":565},{"type":43,"tag":439,"props":2091,"children":2092},{"style":451},[2093],{"type":49,"value":454},{"type":43,"tag":439,"props":2095,"children":2096},{"style":457},[2097],{"type":49,"value":574},{"type":43,"tag":439,"props":2099,"children":2100},{"style":577},[2101],{"type":49,"value":465},{"type":43,"tag":439,"props":2103,"children":2104},{"style":451},[2105],{"type":49,"value":894},{"type":43,"tag":439,"props":2107,"children":2108},{"style":577},[2109],{"type":49,"value":1347},{"type":43,"tag":439,"props":2111,"children":2112},{"style":451},[2113],{"type":49,"value":597},{"type":43,"tag":439,"props":2115,"children":2116},{"style":451},[2117],{"type":49,"value":602},{"type":43,"tag":439,"props":2119,"children":2120},{"style":577},[2121],{"type":49,"value":607},{"type":43,"tag":439,"props":2123,"children":2124},{"style":451},[2125],{"type":49,"value":597},{"type":43,"tag":439,"props":2127,"children":2128},{"style":445},[2129],{"type":49,"value":2130}," userId",{"type":43,"tag":439,"props":2132,"children":2133},{"style":451},[2134],{"type":49,"value":1388},{"type":43,"tag":439,"props":2136,"children":2137},{"style":445},[2138],{"type":49,"value":1393},{"type":43,"tag":439,"props":2140,"children":2141},{"style":451},[2142],{"type":49,"value":920},{"type":43,"tag":439,"props":2144,"children":2145},{"style":577},[2146],{"type":49,"value":516},{"type":43,"tag":439,"props":2148,"children":2149},{"style":451},[2150],{"type":49,"value":742},{"type":43,"tag":439,"props":2152,"children":2153},{"class":441,"line":26},[2154],{"type":43,"tag":439,"props":2155,"children":2156},{"style":781},[2157],{"type":49,"value":2158},"  \u002F\u002F Set cache to the known-correct value, don't just delete it.\n",{"type":43,"tag":439,"props":2160,"children":2161},{"class":441,"line":641},[2162,2166,2171,2175,2180,2184,2188,2193,2197,2201,2205,2209,2213,2217,2221,2225,2229,2233,2237,2241,2246,2250,2254,2259,2263],{"type":43,"tag":439,"props":2163,"children":2164},{"style":548},[2165],{"type":49,"value":1314},{"type":43,"tag":439,"props":2167,"children":2168},{"style":445},[2169],{"type":49,"value":2170}," redis",{"type":43,"tag":439,"props":2172,"children":2173},{"style":451},[2174],{"type":49,"value":454},{"type":43,"tag":439,"props":2176,"children":2177},{"style":457},[2178],{"type":49,"value":2179},"set",{"type":43,"tag":439,"props":2181,"children":2182},{"style":577},[2183],{"type":49,"value":465},{"type":43,"tag":439,"props":2185,"children":2186},{"style":451},[2187],{"type":49,"value":1536},{"type":43,"tag":439,"props":2189,"children":2190},{"style":473},[2191],{"type":49,"value":2192},"user:",{"type":43,"tag":439,"props":2194,"children":2195},{"style":451},[2196],{"type":49,"value":1546},{"type":43,"tag":439,"props":2198,"children":2199},{"style":445},[2200],{"type":49,"value":2013},{"type":43,"tag":439,"props":2202,"children":2203},{"style":451},[2204],{"type":49,"value":1571},{"type":43,"tag":439,"props":2206,"children":2207},{"style":451},[2208],{"type":49,"value":485},{"type":43,"tag":439,"props":2210,"children":2211},{"style":445},[2212],{"type":49,"value":1040},{"type":43,"tag":439,"props":2214,"children":2215},{"style":451},[2216],{"type":49,"value":454},{"type":43,"tag":439,"props":2218,"children":2219},{"style":457},[2220],{"type":49,"value":1049},{"type":43,"tag":439,"props":2222,"children":2223},{"style":577},[2224],{"type":49,"value":465},{"type":43,"tag":439,"props":2226,"children":2227},{"style":445},[2228],{"type":49,"value":769},{"type":43,"tag":439,"props":2230,"children":2231},{"style":577},[2232],{"type":49,"value":516},{"type":43,"tag":439,"props":2234,"children":2235},{"style":451},[2236],{"type":49,"value":485},{"type":43,"tag":439,"props":2238,"children":2239},{"style":451},[2240],{"type":49,"value":1009},{"type":43,"tag":439,"props":2242,"children":2243},{"style":473},[2244],{"type":49,"value":2245},"EX",{"type":43,"tag":439,"props":2247,"children":2248},{"style":451},[2249],{"type":49,"value":470},{"type":43,"tag":439,"props":2251,"children":2252},{"style":451},[2253],{"type":49,"value":485},{"type":43,"tag":439,"props":2255,"children":2256},{"style":1491},[2257],{"type":49,"value":2258}," 300",{"type":43,"tag":439,"props":2260,"children":2261},{"style":577},[2262],{"type":49,"value":516},{"type":43,"tag":439,"props":2264,"children":2265},{"style":451},[2266],{"type":49,"value":742},{"type":43,"tag":439,"props":2268,"children":2269},{"class":441,"line":727},[2270,2275,2279],{"type":43,"tag":439,"props":2271,"children":2272},{"style":548},[2273],{"type":49,"value":2274},"  return",{"type":43,"tag":439,"props":2276,"children":2277},{"style":445},[2278],{"type":49,"value":540},{"type":43,"tag":439,"props":2280,"children":2281},{"style":451},[2282],{"type":49,"value":742},{"type":43,"tag":439,"props":2284,"children":2285},{"class":441,"line":745},[2286],{"type":43,"tag":439,"props":2287,"children":2288},{"style":451},[2289],{"type":49,"value":1221},{"type":43,"tag":52,"props":2291,"children":2292},{},[2293],{"type":49,"value":2294},"Write-through beats delete-then-repopulate: if you delete the key, the next request can read from a stale replica and repopulate with old data.",{"type":43,"tag":421,"props":2296,"children":2298},{"id":2297},"separate-my-stuff-from-browsesearch",[2299],{"type":49,"value":2300},"Separate \"my stuff\" from \"browse\u002Fsearch\"",{"type":43,"tag":428,"props":2302,"children":2304},{"className":430,"code":2303,"language":432,"meta":433,"style":433},"app.get(\"\u002Fapi\u002Fdocuments\", async (req, res) => {\n  if (req.query.q) {\n    \u002F\u002F Search: index (eventual, expected for search)\n    res.json(await searchIndex.search(\"documents\", req.query.q));\n  } else if (req.query.mine) {\n    \u002F\u002F My documents: primary (strong for own data)\n    res.json(await db.document.findMany({\n      where: { authorId: req.user.id }, orderBy: { createdAt: \"desc\" },\n    }));\n  } else {\n    \u002F\u002F Browse all: replica (eventual, fine for discovery)\n    res.json(await readReplica.document.findMany({\n      orderBy: { createdAt: \"desc\" }, take: 50,\n    }));\n  }\n});\n",[2305],{"type":43,"tag":239,"props":2306,"children":2307},{"__ignoreMap":433},[2308,2376,2417,2425,2513,2563,2571,2623,2711,2727,2742,2750,2802,2860,2875,2883],{"type":43,"tag":439,"props":2309,"children":2310},{"class":441,"line":30},[2311,2315,2319,2323,2327,2331,2336,2340,2344,2348,2352,2356,2360,2364,2368,2372],{"type":43,"tag":439,"props":2312,"children":2313},{"style":445},[2314],{"type":49,"value":448},{"type":43,"tag":439,"props":2316,"children":2317},{"style":451},[2318],{"type":49,"value":454},{"type":43,"tag":439,"props":2320,"children":2321},{"style":457},[2322],{"type":49,"value":1617},{"type":43,"tag":439,"props":2324,"children":2325},{"style":445},[2326],{"type":49,"value":465},{"type":43,"tag":439,"props":2328,"children":2329},{"style":451},[2330],{"type":49,"value":470},{"type":43,"tag":439,"props":2332,"children":2333},{"style":473},[2334],{"type":49,"value":2335},"\u002Fapi\u002Fdocuments",{"type":43,"tag":439,"props":2337,"children":2338},{"style":451},[2339],{"type":49,"value":470},{"type":43,"tag":439,"props":2341,"children":2342},{"style":451},[2343],{"type":49,"value":485},{"type":43,"tag":439,"props":2345,"children":2346},{"style":488},[2347],{"type":49,"value":491},{"type":43,"tag":439,"props":2349,"children":2350},{"style":451},[2351],{"type":49,"value":496},{"type":43,"tag":439,"props":2353,"children":2354},{"style":499},[2355],{"type":49,"value":502},{"type":43,"tag":439,"props":2357,"children":2358},{"style":451},[2359],{"type":49,"value":485},{"type":43,"tag":439,"props":2361,"children":2362},{"style":499},[2363],{"type":49,"value":511},{"type":43,"tag":439,"props":2365,"children":2366},{"style":451},[2367],{"type":49,"value":516},{"type":43,"tag":439,"props":2369,"children":2370},{"style":488},[2371],{"type":49,"value":521},{"type":43,"tag":439,"props":2373,"children":2374},{"style":451},[2375],{"type":49,"value":526},{"type":43,"tag":439,"props":2377,"children":2378},{"class":441,"line":529},[2379,2383,2387,2391,2395,2400,2404,2409,2413],{"type":43,"tag":439,"props":2380,"children":2381},{"style":548},[2382],{"type":49,"value":1097},{"type":43,"tag":439,"props":2384,"children":2385},{"style":577},[2386],{"type":49,"value":496},{"type":43,"tag":439,"props":2388,"children":2389},{"style":445},[2390],{"type":49,"value":502},{"type":43,"tag":439,"props":2392,"children":2393},{"style":451},[2394],{"type":49,"value":454},{"type":43,"tag":439,"props":2396,"children":2397},{"style":445},[2398],{"type":49,"value":2399},"query",{"type":43,"tag":439,"props":2401,"children":2402},{"style":451},[2403],{"type":49,"value":454},{"type":43,"tag":439,"props":2405,"children":2406},{"style":445},[2407],{"type":49,"value":2408},"q",{"type":43,"tag":439,"props":2410,"children":2411},{"style":577},[2412],{"type":49,"value":1125},{"type":43,"tag":439,"props":2414,"children":2415},{"style":451},[2416],{"type":49,"value":584},{"type":43,"tag":439,"props":2418,"children":2419},{"class":441,"line":26},[2420],{"type":43,"tag":439,"props":2421,"children":2422},{"style":781},[2423],{"type":49,"value":2424},"    \u002F\u002F Search: index (eventual, expected for search)\n",{"type":43,"tag":439,"props":2426,"children":2427},{"class":441,"line":641},[2428,2433,2437,2441,2445,2450,2455,2459,2464,2468,2472,2477,2481,2485,2489,2493,2497,2501,2505,2509],{"type":43,"tag":439,"props":2429,"children":2430},{"style":445},[2431],{"type":49,"value":2432},"    res",{"type":43,"tag":439,"props":2434,"children":2435},{"style":451},[2436],{"type":49,"value":454},{"type":43,"tag":439,"props":2438,"children":2439},{"style":457},[2440],{"type":49,"value":760},{"type":43,"tag":439,"props":2442,"children":2443},{"style":577},[2444],{"type":49,"value":465},{"type":43,"tag":439,"props":2446,"children":2447},{"style":548},[2448],{"type":49,"value":2449},"await",{"type":43,"tag":439,"props":2451,"children":2452},{"style":445},[2453],{"type":49,"value":2454}," searchIndex",{"type":43,"tag":439,"props":2456,"children":2457},{"style":451},[2458],{"type":49,"value":454},{"type":43,"tag":439,"props":2460,"children":2461},{"style":457},[2462],{"type":49,"value":2463},"search",{"type":43,"tag":439,"props":2465,"children":2466},{"style":577},[2467],{"type":49,"value":465},{"type":43,"tag":439,"props":2469,"children":2470},{"style":451},[2471],{"type":49,"value":470},{"type":43,"tag":439,"props":2473,"children":2474},{"style":473},[2475],{"type":49,"value":2476},"documents",{"type":43,"tag":439,"props":2478,"children":2479},{"style":451},[2480],{"type":49,"value":470},{"type":43,"tag":439,"props":2482,"children":2483},{"style":451},[2484],{"type":49,"value":485},{"type":43,"tag":439,"props":2486,"children":2487},{"style":445},[2488],{"type":49,"value":616},{"type":43,"tag":439,"props":2490,"children":2491},{"style":451},[2492],{"type":49,"value":454},{"type":43,"tag":439,"props":2494,"children":2495},{"style":445},[2496],{"type":49,"value":2399},{"type":43,"tag":439,"props":2498,"children":2499},{"style":451},[2500],{"type":49,"value":454},{"type":43,"tag":439,"props":2502,"children":2503},{"style":445},[2504],{"type":49,"value":2408},{"type":43,"tag":439,"props":2506,"children":2507},{"style":577},[2508],{"type":49,"value":925},{"type":43,"tag":439,"props":2510,"children":2511},{"style":451},[2512],{"type":49,"value":742},{"type":43,"tag":439,"props":2514,"children":2515},{"class":441,"line":727},[2516,2520,2525,2530,2534,2538,2542,2546,2550,2555,2559],{"type":43,"tag":439,"props":2517,"children":2518},{"style":451},[2519],{"type":49,"value":733},{"type":43,"tag":439,"props":2521,"children":2522},{"style":548},[2523],{"type":49,"value":2524}," else",{"type":43,"tag":439,"props":2526,"children":2527},{"style":548},[2528],{"type":49,"value":2529}," if",{"type":43,"tag":439,"props":2531,"children":2532},{"style":577},[2533],{"type":49,"value":496},{"type":43,"tag":439,"props":2535,"children":2536},{"style":445},[2537],{"type":49,"value":502},{"type":43,"tag":439,"props":2539,"children":2540},{"style":451},[2541],{"type":49,"value":454},{"type":43,"tag":439,"props":2543,"children":2544},{"style":445},[2545],{"type":49,"value":2399},{"type":43,"tag":439,"props":2547,"children":2548},{"style":451},[2549],{"type":49,"value":454},{"type":43,"tag":439,"props":2551,"children":2552},{"style":445},[2553],{"type":49,"value":2554},"mine",{"type":43,"tag":439,"props":2556,"children":2557},{"style":577},[2558],{"type":49,"value":1125},{"type":43,"tag":439,"props":2560,"children":2561},{"style":451},[2562],{"type":49,"value":584},{"type":43,"tag":439,"props":2564,"children":2565},{"class":441,"line":745},[2566],{"type":43,"tag":439,"props":2567,"children":2568},{"style":781},[2569],{"type":49,"value":2570},"    \u002F\u002F My documents: primary (strong for own data)\n",{"type":43,"tag":439,"props":2572,"children":2573},{"class":441,"line":787},[2574,2578,2582,2586,2590,2594,2598,2602,2607,2611,2615,2619],{"type":43,"tag":439,"props":2575,"children":2576},{"style":445},[2577],{"type":49,"value":2432},{"type":43,"tag":439,"props":2579,"children":2580},{"style":451},[2581],{"type":49,"value":454},{"type":43,"tag":439,"props":2583,"children":2584},{"style":457},[2585],{"type":49,"value":760},{"type":43,"tag":439,"props":2587,"children":2588},{"style":577},[2589],{"type":49,"value":465},{"type":43,"tag":439,"props":2591,"children":2592},{"style":548},[2593],{"type":49,"value":2449},{"type":43,"tag":439,"props":2595,"children":2596},{"style":445},[2597],{"type":49,"value":556},{"type":43,"tag":439,"props":2599,"children":2600},{"style":451},[2601],{"type":49,"value":454},{"type":43,"tag":439,"props":2603,"children":2604},{"style":445},[2605],{"type":49,"value":2606},"document",{"type":43,"tag":439,"props":2608,"children":2609},{"style":451},[2610],{"type":49,"value":454},{"type":43,"tag":439,"props":2612,"children":2613},{"style":457},[2614],{"type":49,"value":244},{"type":43,"tag":439,"props":2616,"children":2617},{"style":577},[2618],{"type":49,"value":465},{"type":43,"tag":439,"props":2620,"children":2621},{"style":451},[2622],{"type":49,"value":584},{"type":43,"tag":439,"props":2624,"children":2625},{"class":441,"line":1083},[2626,2631,2635,2639,2644,2648,2652,2656,2660,2664,2668,2672,2677,2681,2685,2690,2694,2698,2703,2707],{"type":43,"tag":439,"props":2627,"children":2628},{"style":577},[2629],{"type":49,"value":2630},"      where",{"type":43,"tag":439,"props":2632,"children":2633},{"style":451},[2634],{"type":49,"value":597},{"type":43,"tag":439,"props":2636,"children":2637},{"style":451},[2638],{"type":49,"value":602},{"type":43,"tag":439,"props":2640,"children":2641},{"style":577},[2642],{"type":49,"value":2643}," authorId",{"type":43,"tag":439,"props":2645,"children":2646},{"style":451},[2647],{"type":49,"value":597},{"type":43,"tag":439,"props":2649,"children":2650},{"style":445},[2651],{"type":49,"value":616},{"type":43,"tag":439,"props":2653,"children":2654},{"style":451},[2655],{"type":49,"value":454},{"type":43,"tag":439,"props":2657,"children":2658},{"style":445},[2659],{"type":49,"value":565},{"type":43,"tag":439,"props":2661,"children":2662},{"style":451},[2663],{"type":49,"value":454},{"type":43,"tag":439,"props":2665,"children":2666},{"style":445},[2667],{"type":49,"value":633},{"type":43,"tag":439,"props":2669,"children":2670},{"style":451},[2671],{"type":49,"value":1388},{"type":43,"tag":439,"props":2673,"children":2674},{"style":577},[2675],{"type":49,"value":2676}," orderBy",{"type":43,"tag":439,"props":2678,"children":2679},{"style":451},[2680],{"type":49,"value":597},{"type":43,"tag":439,"props":2682,"children":2683},{"style":451},[2684],{"type":49,"value":602},{"type":43,"tag":439,"props":2686,"children":2687},{"style":577},[2688],{"type":49,"value":2689}," createdAt",{"type":43,"tag":439,"props":2691,"children":2692},{"style":451},[2693],{"type":49,"value":597},{"type":43,"tag":439,"props":2695,"children":2696},{"style":451},[2697],{"type":49,"value":1009},{"type":43,"tag":439,"props":2699,"children":2700},{"style":473},[2701],{"type":49,"value":2702},"desc",{"type":43,"tag":439,"props":2704,"children":2705},{"style":451},[2706],{"type":49,"value":470},{"type":43,"tag":439,"props":2708,"children":2709},{"style":451},[2710],{"type":49,"value":638},{"type":43,"tag":439,"props":2712,"children":2713},{"class":441,"line":1091},[2714,2719,2723],{"type":43,"tag":439,"props":2715,"children":2716},{"style":451},[2717],{"type":49,"value":2718},"    }",{"type":43,"tag":439,"props":2720,"children":2721},{"style":577},[2722],{"type":49,"value":925},{"type":43,"tag":439,"props":2724,"children":2725},{"style":451},[2726],{"type":49,"value":742},{"type":43,"tag":439,"props":2728,"children":2729},{"class":441,"line":1132},[2730,2734,2738],{"type":43,"tag":439,"props":2731,"children":2732},{"style":451},[2733],{"type":49,"value":733},{"type":43,"tag":439,"props":2735,"children":2736},{"style":548},[2737],{"type":49,"value":2524},{"type":43,"tag":439,"props":2739,"children":2740},{"style":451},[2741],{"type":49,"value":526},{"type":43,"tag":439,"props":2743,"children":2744},{"class":441,"line":1163},[2745],{"type":43,"tag":439,"props":2746,"children":2747},{"style":781},[2748],{"type":49,"value":2749},"    \u002F\u002F Browse all: replica (eventual, fine for discovery)\n",{"type":43,"tag":439,"props":2751,"children":2752},{"class":441,"line":1197},[2753,2757,2761,2765,2769,2773,2778,2782,2786,2790,2794,2798],{"type":43,"tag":439,"props":2754,"children":2755},{"style":445},[2756],{"type":49,"value":2432},{"type":43,"tag":439,"props":2758,"children":2759},{"style":451},[2760],{"type":49,"value":454},{"type":43,"tag":439,"props":2762,"children":2763},{"style":457},[2764],{"type":49,"value":760},{"type":43,"tag":439,"props":2766,"children":2767},{"style":577},[2768],{"type":49,"value":465},{"type":43,"tag":439,"props":2770,"children":2771},{"style":548},[2772],{"type":49,"value":2449},{"type":43,"tag":439,"props":2774,"children":2775},{"style":445},[2776],{"type":49,"value":2777}," readReplica",{"type":43,"tag":439,"props":2779,"children":2780},{"style":451},[2781],{"type":49,"value":454},{"type":43,"tag":439,"props":2783,"children":2784},{"style":445},[2785],{"type":49,"value":2606},{"type":43,"tag":439,"props":2787,"children":2788},{"style":451},[2789],{"type":49,"value":454},{"type":43,"tag":439,"props":2791,"children":2792},{"style":457},[2793],{"type":49,"value":244},{"type":43,"tag":439,"props":2795,"children":2796},{"style":577},[2797],{"type":49,"value":465},{"type":43,"tag":439,"props":2799,"children":2800},{"style":451},[2801],{"type":49,"value":584},{"type":43,"tag":439,"props":2803,"children":2804},{"class":441,"line":1206},[2805,2810,2814,2818,2822,2826,2830,2834,2838,2842,2847,2851,2856],{"type":43,"tag":439,"props":2806,"children":2807},{"style":577},[2808],{"type":49,"value":2809},"      orderBy",{"type":43,"tag":439,"props":2811,"children":2812},{"style":451},[2813],{"type":49,"value":597},{"type":43,"tag":439,"props":2815,"children":2816},{"style":451},[2817],{"type":49,"value":602},{"type":43,"tag":439,"props":2819,"children":2820},{"style":577},[2821],{"type":49,"value":2689},{"type":43,"tag":439,"props":2823,"children":2824},{"style":451},[2825],{"type":49,"value":597},{"type":43,"tag":439,"props":2827,"children":2828},{"style":451},[2829],{"type":49,"value":1009},{"type":43,"tag":439,"props":2831,"children":2832},{"style":473},[2833],{"type":49,"value":2702},{"type":43,"tag":439,"props":2835,"children":2836},{"style":451},[2837],{"type":49,"value":470},{"type":43,"tag":439,"props":2839,"children":2840},{"style":451},[2841],{"type":49,"value":1388},{"type":43,"tag":439,"props":2843,"children":2844},{"style":577},[2845],{"type":49,"value":2846}," take",{"type":43,"tag":439,"props":2848,"children":2849},{"style":451},[2850],{"type":49,"value":597},{"type":43,"tag":439,"props":2852,"children":2853},{"style":1491},[2854],{"type":49,"value":2855}," 50",{"type":43,"tag":439,"props":2857,"children":2858},{"style":451},[2859],{"type":49,"value":1023},{"type":43,"tag":439,"props":2861,"children":2862},{"class":441,"line":1215},[2863,2867,2871],{"type":43,"tag":439,"props":2864,"children":2865},{"style":451},[2866],{"type":49,"value":2718},{"type":43,"tag":439,"props":2868,"children":2869},{"style":577},[2870],{"type":49,"value":925},{"type":43,"tag":439,"props":2872,"children":2873},{"style":451},[2874],{"type":49,"value":742},{"type":43,"tag":439,"props":2876,"children":2878},{"class":441,"line":2877},15,[2879],{"type":43,"tag":439,"props":2880,"children":2881},{"style":451},[2882],{"type":49,"value":1203},{"type":43,"tag":439,"props":2884,"children":2886},{"class":441,"line":2885},16,[2887,2891,2895],{"type":43,"tag":439,"props":2888,"children":2889},{"style":451},[2890],{"type":49,"value":793},{"type":43,"tag":439,"props":2892,"children":2893},{"style":445},[2894],{"type":49,"value":516},{"type":43,"tag":439,"props":2896,"children":2897},{"style":451},[2898],{"type":49,"value":742},{"type":43,"tag":52,"props":2900,"children":2901},{},[2902],{"type":49,"value":2903},"Different reads, different consistency requirements, different backends.",{"type":43,"tag":64,"props":2905,"children":2907},{"id":2906},"know-your-databases-consistency-model",[2908],{"type":49,"value":2909},"Know Your Database's Consistency Model",{"type":43,"tag":52,"props":2911,"children":2912},{},[2913],{"type":49,"value":2914},"Every database has a default consistency model. Assume stronger guarantees than you have and you'll write stale-read bugs. Defaults and the trap for each:",{"type":43,"tag":2916,"props":2917,"children":2918},"ul",{},[2919,2937,2953,2969,3025,3080,3141,3165],{"type":43,"tag":190,"props":2920,"children":2921},{},[2922,2927,2929,2935],{"type":43,"tag":58,"props":2923,"children":2924},{},[2925],{"type":49,"value":2926},"PostgreSQL",{"type":49,"value":2928}," -- Strong on a single instance. Streaming (async) replication is the standard HA setup, with 10-500ms replica lag; synchronous replication removes lag but adds write latency. ",{"type":43,"tag":2930,"props":2931,"children":2932},"em",{},[2933],{"type":49,"value":2934},"Trap:",{"type":49,"value":2936}," Prisma\u002FRails\u002FDjango can transparently route reads to replicas -- your ORM may read a replica without you knowing.",{"type":43,"tag":190,"props":2938,"children":2939},{},[2940,2945,2947,2951],{"type":43,"tag":58,"props":2941,"children":2942},{},[2943],{"type":49,"value":2944},"MySQL \u002F Aurora MySQL",{"type":49,"value":2946}," -- Strong on single instance. Aurora replicas lag ~10-20ms (shared storage); standard async replicas lag seconds-to-minutes under load. Aurora reader-endpoint affinity can route post-write reads to the writer. ",{"type":43,"tag":2930,"props":2948,"children":2949},{},[2950],{"type":49,"value":2934},{"type":49,"value":2952}," cluster endpoint (writes) vs reader endpoint (replicas) -- a reader connection string means you're reading replicas.",{"type":43,"tag":190,"props":2954,"children":2955},{},[2956,2961,2963,2967],{"type":43,"tag":58,"props":2957,"children":2958},{},[2959],{"type":49,"value":2960},"Redis",{"type":49,"value":2962}," -- Eventual with async replication; no guarantee a replica has the latest write. ",{"type":43,"tag":2930,"props":2964,"children":2965},{},[2966],{"type":49,"value":2934},{"type":49,"value":2968}," stale cache reads from replicas are by design; for coordination (locks, rate limiting) always read\u002Fwrite the primary.",{"type":43,"tag":190,"props":2970,"children":2971},{},[2972,2977,2979,2985,2987,2993,2995,3001,3003,3009,3011,3017,3019,3023],{"type":43,"tag":58,"props":2973,"children":2974},{},[2975],{"type":49,"value":2976},"ClickHouse",{"type":49,"value":2978}," -- Eventual; built for analytics where slight staleness is fine. Inserts are async by default (local buffer, async replication), so a query right after insert may miss the data. ",{"type":43,"tag":239,"props":2980,"children":2982},{"className":2981},[],[2983],{"type":49,"value":2984},"insert_quorum",{"type":49,"value":2986}," forces synchronous writes to N replicas; ",{"type":43,"tag":239,"props":2988,"children":2990},{"className":2989},[],[2991],{"type":49,"value":2992},"select_sequential_consistency=1",{"type":49,"value":2994}," forces reads to wait for latest -- both expensive. ReplicatedMergeTree still replicates async. MergeTree merges run in the background, so queries can see duplicate rows until merge completes unless you use ",{"type":43,"tag":239,"props":2996,"children":2998},{"className":2997},[],[2999],{"type":49,"value":3000},"ReplacingMergeTree",{"type":49,"value":3002}," with ",{"type":43,"tag":239,"props":3004,"children":3006},{"className":3005},[],[3007],{"type":49,"value":3008},"FINAL",{"type":49,"value":3010}," (or ",{"type":43,"tag":239,"props":3012,"children":3014},{"className":3013},[],[3015],{"type":49,"value":3016},"OPTIMIZE TABLE ... FINAL",{"type":49,"value":3018},", expensive). ",{"type":43,"tag":2930,"props":3020,"children":3021},{},[3022],{"type":49,"value":2934},{"type":49,"value":3024}," write-then-immediately-query works single-node in dev, fails with distributed tables in prod -- assume reads are stale unless quorum writes are configured.",{"type":43,"tag":190,"props":3026,"children":3027},{},[3028,3033,3035,3041,3043,3049,3051,3057,3059,3063,3065,3070,3072,3078],{"type":43,"tag":58,"props":3029,"children":3030},{},[3031],{"type":49,"value":3032},"MongoDB",{"type":49,"value":3034}," -- Eventual with replica sets; secondaries may be stale. Read concern: ",{"type":43,"tag":239,"props":3036,"children":3038},{"className":3037},[],[3039],{"type":49,"value":3040},"\"local\"",{"type":49,"value":3042}," (default, may be stale), ",{"type":43,"tag":239,"props":3044,"children":3046},{"className":3045},[],[3047],{"type":49,"value":3048},"\"majority\"",{"type":49,"value":3050},", ",{"type":43,"tag":239,"props":3052,"children":3054},{"className":3053},[],[3055],{"type":49,"value":3056},"\"linearizable\"",{"type":49,"value":3058}," (strongest, slowest). ",{"type":43,"tag":2930,"props":3060,"children":3061},{},[3062],{"type":49,"value":2934},{"type":49,"value":3064}," default ",{"type":43,"tag":239,"props":3066,"children":3068},{"className":3067},[],[3069],{"type":49,"value":3040},{"type":49,"value":3071}," read + default ",{"type":43,"tag":239,"props":3073,"children":3075},{"className":3074},[],[3076],{"type":49,"value":3077},"w:1",{"type":49,"value":3079}," write means you can lose acknowledged writes if the primary fails before replication.",{"type":43,"tag":190,"props":3081,"children":3082},{},[3083,3088,3090,3096,3098,3104,3106,3112,3114,3118,3120,3125,3127,3133,3135,3140],{"type":43,"tag":58,"props":3084,"children":3085},{},[3086],{"type":49,"value":3087},"DynamoDB",{"type":49,"value":3089}," -- Eventual reads by default; ",{"type":43,"tag":239,"props":3091,"children":3093},{"className":3092},[],[3094],{"type":49,"value":3095},"GetItem",{"type":49,"value":3097},"\u002F",{"type":43,"tag":239,"props":3099,"children":3101},{"className":3100},[],[3102],{"type":49,"value":3103},"Query",{"type":49,"value":3105}," need ",{"type":43,"tag":239,"props":3107,"children":3109},{"className":3108},[],[3110],{"type":49,"value":3111},"ConsistentRead: true",{"type":49,"value":3113}," (2x read cost) to see the latest. Global tables resolve cross-region conflicts last-writer-wins. ",{"type":43,"tag":2930,"props":3115,"children":3116},{},[3117],{"type":49,"value":2934},{"type":49,"value":3119}," SDK defaults give eventual consistency silently -- a ",{"type":43,"tag":239,"props":3121,"children":3123},{"className":3122},[],[3124],{"type":49,"value":3095},{"type":49,"value":3126}," that must see a prior ",{"type":43,"tag":239,"props":3128,"children":3130},{"className":3129},[],[3131],{"type":49,"value":3132},"PutItem",{"type":49,"value":3134}," needs ",{"type":43,"tag":239,"props":3136,"children":3138},{"className":3137},[],[3139],{"type":49,"value":3111},{"type":49,"value":454},{"type":43,"tag":190,"props":3142,"children":3143},{},[3144,3149,3151,3157,3159,3163],{"type":43,"tag":58,"props":3145,"children":3146},{},[3147],{"type":49,"value":3148},"Elasticsearch \u002F OpenSearch",{"type":49,"value":3150}," -- Near-real-time (eventual): an indexed doc isn't searchable until the next refresh (default 1s; bulk slower). ",{"type":43,"tag":239,"props":3152,"children":3154},{"className":3153},[],[3155],{"type":49,"value":3156},"refresh=wait_for",{"type":49,"value":3158}," forces a refresh before returning, at a latency cost. ",{"type":43,"tag":2930,"props":3160,"children":3161},{},[3162],{"type":49,"value":2934},{"type":49,"value":3164}," \"just indexed, can't find it\" -- the index hasn't refreshed; consistency is traded for search throughput.",{"type":43,"tag":190,"props":3166,"children":3167},{},[3168,3173,3175,3179],{"type":43,"tag":58,"props":3169,"children":3170},{},[3171],{"type":49,"value":3172},"S3",{"type":49,"value":3174}," -- Strong read-after-write since 2020: a GET after a successful PUT returns the latest. ",{"type":43,"tag":2930,"props":3176,"children":3177},{},[3178],{"type":49,"value":2934},{"type":49,"value":3180}," LIST can still lag -- a newly PUT object may not appear in a LIST immediately. See the Object Store as Database skill for conditional writes.",{"type":43,"tag":64,"props":3182,"children":3184},{"id":3183},"anti-patterns",[3185],{"type":49,"value":3186},"Anti-Patterns",{"type":43,"tag":428,"props":3188,"children":3190},{"className":430,"code":3189,"language":432,"meta":433,"style":433},"\u002F\u002F Dangerous: create then redirect. \u002Forders\u002F:id reads a replica; order may not be there yet.\napp.post(\"\u002Fapi\u002Forders\", async (req, res) => {\n  const order = await db.order.create({ data: req.body });\n  res.redirect(`\u002Forders\u002F${order.id}`);\n});\n\n\u002F\u002F Dangerous: update database, read from cache on next request (stale until TTL expires)\nawait db.user.update({ where: { id }, data: { name: \"New Name\" } });\nconst cached = await redis.get(`user:${id}`); \u002F\u002F still \"Old Name\"\n\n\u002F\u002F Dangerous: create in database, immediately search for it (index hasn't refreshed)\nawait db.document.create({ data: { title: \"Q4 Report\", content: \"...\" } });\nawait searchIndex.index(\"documents\", doc.id, doc);\n\u002F\u002F User searches \"Q4 Report\" -- not found\n\n\u002F\u002F Dangerous: publish event, query read model on next page (consumer hasn't run)\nawait eventBus.publish(\"order.created\", order);\nres.redirect(\"\u002Forders\");\n",[3191],{"type":43,"tag":239,"props":3192,"children":3193},{"__ignoreMap":433},[3194,3202,3270,3352,3408,3423,3430,3438,3544,3615,3622,3630,3741,3807,3815,3822,3830,3882],{"type":43,"tag":439,"props":3195,"children":3196},{"class":441,"line":30},[3197],{"type":43,"tag":439,"props":3198,"children":3199},{"style":781},[3200],{"type":49,"value":3201},"\u002F\u002F Dangerous: create then redirect. \u002Forders\u002F:id reads a replica; order may not be there yet.\n",{"type":43,"tag":439,"props":3203,"children":3204},{"class":441,"line":529},[3205,3209,3213,3217,3221,3225,3230,3234,3238,3242,3246,3250,3254,3258,3262,3266],{"type":43,"tag":439,"props":3206,"children":3207},{"style":445},[3208],{"type":49,"value":448},{"type":43,"tag":439,"props":3210,"children":3211},{"style":451},[3212],{"type":49,"value":454},{"type":43,"tag":439,"props":3214,"children":3215},{"style":457},[3216],{"type":49,"value":460},{"type":43,"tag":439,"props":3218,"children":3219},{"style":445},[3220],{"type":49,"value":465},{"type":43,"tag":439,"props":3222,"children":3223},{"style":451},[3224],{"type":49,"value":470},{"type":43,"tag":439,"props":3226,"children":3227},{"style":473},[3228],{"type":49,"value":3229},"\u002Fapi\u002Forders",{"type":43,"tag":439,"props":3231,"children":3232},{"style":451},[3233],{"type":49,"value":470},{"type":43,"tag":439,"props":3235,"children":3236},{"style":451},[3237],{"type":49,"value":485},{"type":43,"tag":439,"props":3239,"children":3240},{"style":488},[3241],{"type":49,"value":491},{"type":43,"tag":439,"props":3243,"children":3244},{"style":451},[3245],{"type":49,"value":496},{"type":43,"tag":439,"props":3247,"children":3248},{"style":499},[3249],{"type":49,"value":502},{"type":43,"tag":439,"props":3251,"children":3252},{"style":451},[3253],{"type":49,"value":485},{"type":43,"tag":439,"props":3255,"children":3256},{"style":499},[3257],{"type":49,"value":511},{"type":43,"tag":439,"props":3259,"children":3260},{"style":451},[3261],{"type":49,"value":516},{"type":43,"tag":439,"props":3263,"children":3264},{"style":488},[3265],{"type":49,"value":521},{"type":43,"tag":439,"props":3267,"children":3268},{"style":451},[3269],{"type":49,"value":526},{"type":43,"tag":439,"props":3271,"children":3272},{"class":441,"line":26},[3273,3277,3282,3286,3290,3294,3298,3303,3307,3312,3316,3320,3324,3328,3332,3336,3340,3344,3348],{"type":43,"tag":439,"props":3274,"children":3275},{"style":488},[3276],{"type":49,"value":535},{"type":43,"tag":439,"props":3278,"children":3279},{"style":445},[3280],{"type":49,"value":3281}," order",{"type":43,"tag":439,"props":3283,"children":3284},{"style":451},[3285],{"type":49,"value":545},{"type":43,"tag":439,"props":3287,"children":3288},{"style":548},[3289],{"type":49,"value":551},{"type":43,"tag":439,"props":3291,"children":3292},{"style":445},[3293],{"type":49,"value":556},{"type":43,"tag":439,"props":3295,"children":3296},{"style":451},[3297],{"type":49,"value":454},{"type":43,"tag":439,"props":3299,"children":3300},{"style":445},[3301],{"type":49,"value":3302},"order",{"type":43,"tag":439,"props":3304,"children":3305},{"style":451},[3306],{"type":49,"value":454},{"type":43,"tag":439,"props":3308,"children":3309},{"style":457},[3310],{"type":49,"value":3311},"create",{"type":43,"tag":439,"props":3313,"children":3314},{"style":577},[3315],{"type":49,"value":465},{"type":43,"tag":439,"props":3317,"children":3318},{"style":451},[3319],{"type":49,"value":894},{"type":43,"tag":439,"props":3321,"children":3322},{"style":577},[3323],{"type":49,"value":1393},{"type":43,"tag":439,"props":3325,"children":3326},{"style":451},[3327],{"type":49,"value":597},{"type":43,"tag":439,"props":3329,"children":3330},{"style":445},[3331],{"type":49,"value":616},{"type":43,"tag":439,"props":3333,"children":3334},{"style":451},[3335],{"type":49,"value":454},{"type":43,"tag":439,"props":3337,"children":3338},{"style":445},[3339],{"type":49,"value":677},{"type":43,"tag":439,"props":3341,"children":3342},{"style":451},[3343],{"type":49,"value":920},{"type":43,"tag":439,"props":3345,"children":3346},{"style":577},[3347],{"type":49,"value":516},{"type":43,"tag":439,"props":3349,"children":3350},{"style":451},[3351],{"type":49,"value":742},{"type":43,"tag":439,"props":3353,"children":3354},{"class":441,"line":641},[3355,3359,3363,3367,3371,3375,3380,3384,3388,3392,3396,3400,3404],{"type":43,"tag":439,"props":3356,"children":3357},{"style":445},[3358],{"type":49,"value":751},{"type":43,"tag":439,"props":3360,"children":3361},{"style":451},[3362],{"type":49,"value":454},{"type":43,"tag":439,"props":3364,"children":3365},{"style":457},[3366],{"type":49,"value":1527},{"type":43,"tag":439,"props":3368,"children":3369},{"style":577},[3370],{"type":49,"value":465},{"type":43,"tag":439,"props":3372,"children":3373},{"style":451},[3374],{"type":49,"value":1536},{"type":43,"tag":439,"props":3376,"children":3377},{"style":473},[3378],{"type":49,"value":3379},"\u002Forders\u002F",{"type":43,"tag":439,"props":3381,"children":3382},{"style":451},[3383],{"type":49,"value":1546},{"type":43,"tag":439,"props":3385,"children":3386},{"style":445},[3387],{"type":49,"value":3302},{"type":43,"tag":439,"props":3389,"children":3390},{"style":451},[3391],{"type":49,"value":454},{"type":43,"tag":439,"props":3393,"children":3394},{"style":445},[3395],{"type":49,"value":633},{"type":43,"tag":439,"props":3397,"children":3398},{"style":451},[3399],{"type":49,"value":1571},{"type":43,"tag":439,"props":3401,"children":3402},{"style":577},[3403],{"type":49,"value":516},{"type":43,"tag":439,"props":3405,"children":3406},{"style":451},[3407],{"type":49,"value":742},{"type":43,"tag":439,"props":3409,"children":3410},{"class":441,"line":727},[3411,3415,3419],{"type":43,"tag":439,"props":3412,"children":3413},{"style":451},[3414],{"type":49,"value":793},{"type":43,"tag":439,"props":3416,"children":3417},{"style":445},[3418],{"type":49,"value":516},{"type":43,"tag":439,"props":3420,"children":3421},{"style":451},[3422],{"type":49,"value":742},{"type":43,"tag":439,"props":3424,"children":3425},{"class":441,"line":745},[3426],{"type":43,"tag":439,"props":3427,"children":3428},{"emptyLinePlaceholder":940},[3429],{"type":49,"value":943},{"type":43,"tag":439,"props":3431,"children":3432},{"class":441,"line":787},[3433],{"type":43,"tag":439,"props":3434,"children":3435},{"style":781},[3436],{"type":49,"value":3437},"\u002F\u002F Dangerous: update database, read from cache on next request (stale until TTL expires)\n",{"type":43,"tag":439,"props":3439,"children":3440},{"class":441,"line":1083},[3441,3445,3449,3453,3457,3461,3465,3469,3473,3477,3481,3485,3490,3495,3499,3503,3507,3511,3515,3519,3524,3528,3532,3536,3540],{"type":43,"tag":439,"props":3442,"children":3443},{"style":548},[3444],{"type":49,"value":2449},{"type":43,"tag":439,"props":3446,"children":3447},{"style":445},[3448],{"type":49,"value":556},{"type":43,"tag":439,"props":3450,"children":3451},{"style":451},[3452],{"type":49,"value":454},{"type":43,"tag":439,"props":3454,"children":3455},{"style":445},[3456],{"type":49,"value":565},{"type":43,"tag":439,"props":3458,"children":3459},{"style":451},[3460],{"type":49,"value":454},{"type":43,"tag":439,"props":3462,"children":3463},{"style":457},[3464],{"type":49,"value":574},{"type":43,"tag":439,"props":3466,"children":3467},{"style":445},[3468],{"type":49,"value":465},{"type":43,"tag":439,"props":3470,"children":3471},{"style":451},[3472],{"type":49,"value":894},{"type":43,"tag":439,"props":3474,"children":3475},{"style":577},[3476],{"type":49,"value":1347},{"type":43,"tag":439,"props":3478,"children":3479},{"style":451},[3480],{"type":49,"value":597},{"type":43,"tag":439,"props":3482,"children":3483},{"style":451},[3484],{"type":49,"value":602},{"type":43,"tag":439,"props":3486,"children":3487},{"style":445},[3488],{"type":49,"value":3489}," id ",{"type":43,"tag":439,"props":3491,"children":3492},{"style":451},[3493],{"type":49,"value":3494},"},",{"type":43,"tag":439,"props":3496,"children":3497},{"style":577},[3498],{"type":49,"value":1393},{"type":43,"tag":439,"props":3500,"children":3501},{"style":451},[3502],{"type":49,"value":597},{"type":43,"tag":439,"props":3504,"children":3505},{"style":451},[3506],{"type":49,"value":602},{"type":43,"tag":439,"props":3508,"children":3509},{"style":577},[3510],{"type":49,"value":660},{"type":43,"tag":439,"props":3512,"children":3513},{"style":451},[3514],{"type":49,"value":597},{"type":43,"tag":439,"props":3516,"children":3517},{"style":451},[3518],{"type":49,"value":1009},{"type":43,"tag":439,"props":3520,"children":3521},{"style":473},[3522],{"type":49,"value":3523},"New Name",{"type":43,"tag":439,"props":3525,"children":3526},{"style":451},[3527],{"type":49,"value":470},{"type":43,"tag":439,"props":3529,"children":3530},{"style":451},[3531],{"type":49,"value":920},{"type":43,"tag":439,"props":3533,"children":3534},{"style":451},[3535],{"type":49,"value":920},{"type":43,"tag":439,"props":3537,"children":3538},{"style":445},[3539],{"type":49,"value":516},{"type":43,"tag":439,"props":3541,"children":3542},{"style":451},[3543],{"type":49,"value":742},{"type":43,"tag":439,"props":3545,"children":3546},{"class":441,"line":1091},[3547,3552,3557,3562,3566,3570,3574,3578,3582,3586,3590,3594,3598,3602,3606,3610],{"type":43,"tag":439,"props":3548,"children":3549},{"style":488},[3550],{"type":49,"value":3551},"const",{"type":43,"tag":439,"props":3553,"children":3554},{"style":445},[3555],{"type":49,"value":3556}," cached ",{"type":43,"tag":439,"props":3558,"children":3559},{"style":451},[3560],{"type":49,"value":3561},"=",{"type":43,"tag":439,"props":3563,"children":3564},{"style":548},[3565],{"type":49,"value":551},{"type":43,"tag":439,"props":3567,"children":3568},{"style":445},[3569],{"type":49,"value":2170},{"type":43,"tag":439,"props":3571,"children":3572},{"style":451},[3573],{"type":49,"value":454},{"type":43,"tag":439,"props":3575,"children":3576},{"style":457},[3577],{"type":49,"value":1617},{"type":43,"tag":439,"props":3579,"children":3580},{"style":445},[3581],{"type":49,"value":465},{"type":43,"tag":439,"props":3583,"children":3584},{"style":451},[3585],{"type":49,"value":1536},{"type":43,"tag":439,"props":3587,"children":3588},{"style":473},[3589],{"type":49,"value":2192},{"type":43,"tag":439,"props":3591,"children":3592},{"style":451},[3593],{"type":49,"value":1546},{"type":43,"tag":439,"props":3595,"children":3596},{"style":445},[3597],{"type":49,"value":633},{"type":43,"tag":439,"props":3599,"children":3600},{"style":451},[3601],{"type":49,"value":1571},{"type":43,"tag":439,"props":3603,"children":3604},{"style":445},[3605],{"type":49,"value":516},{"type":43,"tag":439,"props":3607,"children":3608},{"style":451},[3609],{"type":49,"value":778},{"type":43,"tag":439,"props":3611,"children":3612},{"style":781},[3613],{"type":49,"value":3614}," \u002F\u002F still \"Old Name\"\n",{"type":43,"tag":439,"props":3616,"children":3617},{"class":441,"line":1132},[3618],{"type":43,"tag":439,"props":3619,"children":3620},{"emptyLinePlaceholder":940},[3621],{"type":49,"value":943},{"type":43,"tag":439,"props":3623,"children":3624},{"class":441,"line":1163},[3625],{"type":43,"tag":439,"props":3626,"children":3627},{"style":781},[3628],{"type":49,"value":3629},"\u002F\u002F Dangerous: create in database, immediately search for it (index hasn't refreshed)\n",{"type":43,"tag":439,"props":3631,"children":3632},{"class":441,"line":1197},[3633,3637,3641,3645,3649,3653,3657,3661,3665,3669,3673,3677,3682,3686,3690,3695,3699,3703,3708,3712,3716,3721,3725,3729,3733,3737],{"type":43,"tag":439,"props":3634,"children":3635},{"style":548},[3636],{"type":49,"value":2449},{"type":43,"tag":439,"props":3638,"children":3639},{"style":445},[3640],{"type":49,"value":556},{"type":43,"tag":439,"props":3642,"children":3643},{"style":451},[3644],{"type":49,"value":454},{"type":43,"tag":439,"props":3646,"children":3647},{"style":445},[3648],{"type":49,"value":2606},{"type":43,"tag":439,"props":3650,"children":3651},{"style":451},[3652],{"type":49,"value":454},{"type":43,"tag":439,"props":3654,"children":3655},{"style":457},[3656],{"type":49,"value":3311},{"type":43,"tag":439,"props":3658,"children":3659},{"style":445},[3660],{"type":49,"value":465},{"type":43,"tag":439,"props":3662,"children":3663},{"style":451},[3664],{"type":49,"value":894},{"type":43,"tag":439,"props":3666,"children":3667},{"style":577},[3668],{"type":49,"value":1393},{"type":43,"tag":439,"props":3670,"children":3671},{"style":451},[3672],{"type":49,"value":597},{"type":43,"tag":439,"props":3674,"children":3675},{"style":451},[3676],{"type":49,"value":602},{"type":43,"tag":439,"props":3678,"children":3679},{"style":577},[3680],{"type":49,"value":3681}," title",{"type":43,"tag":439,"props":3683,"children":3684},{"style":451},[3685],{"type":49,"value":597},{"type":43,"tag":439,"props":3687,"children":3688},{"style":451},[3689],{"type":49,"value":1009},{"type":43,"tag":439,"props":3691,"children":3692},{"style":473},[3693],{"type":49,"value":3694},"Q4 Report",{"type":43,"tag":439,"props":3696,"children":3697},{"style":451},[3698],{"type":49,"value":470},{"type":43,"tag":439,"props":3700,"children":3701},{"style":451},[3702],{"type":49,"value":485},{"type":43,"tag":439,"props":3704,"children":3705},{"style":577},[3706],{"type":49,"value":3707}," content",{"type":43,"tag":439,"props":3709,"children":3710},{"style":451},[3711],{"type":49,"value":597},{"type":43,"tag":439,"props":3713,"children":3714},{"style":451},[3715],{"type":49,"value":1009},{"type":43,"tag":439,"props":3717,"children":3718},{"style":473},[3719],{"type":49,"value":3720},"...",{"type":43,"tag":439,"props":3722,"children":3723},{"style":451},[3724],{"type":49,"value":470},{"type":43,"tag":439,"props":3726,"children":3727},{"style":451},[3728],{"type":49,"value":920},{"type":43,"tag":439,"props":3730,"children":3731},{"style":451},[3732],{"type":49,"value":920},{"type":43,"tag":439,"props":3734,"children":3735},{"style":445},[3736],{"type":49,"value":516},{"type":43,"tag":439,"props":3738,"children":3739},{"style":451},[3740],{"type":49,"value":742},{"type":43,"tag":439,"props":3742,"children":3743},{"class":441,"line":1206},[3744,3748,3752,3756,3761,3765,3769,3773,3777,3781,3786,3790,3794,3798,3803],{"type":43,"tag":439,"props":3745,"children":3746},{"style":548},[3747],{"type":49,"value":2449},{"type":43,"tag":439,"props":3749,"children":3750},{"style":445},[3751],{"type":49,"value":2454},{"type":43,"tag":439,"props":3753,"children":3754},{"style":451},[3755],{"type":49,"value":454},{"type":43,"tag":439,"props":3757,"children":3758},{"style":457},[3759],{"type":49,"value":3760},"index",{"type":43,"tag":439,"props":3762,"children":3763},{"style":445},[3764],{"type":49,"value":465},{"type":43,"tag":439,"props":3766,"children":3767},{"style":451},[3768],{"type":49,"value":470},{"type":43,"tag":439,"props":3770,"children":3771},{"style":473},[3772],{"type":49,"value":2476},{"type":43,"tag":439,"props":3774,"children":3775},{"style":451},[3776],{"type":49,"value":470},{"type":43,"tag":439,"props":3778,"children":3779},{"style":451},[3780],{"type":49,"value":485},{"type":43,"tag":439,"props":3782,"children":3783},{"style":445},[3784],{"type":49,"value":3785}," doc",{"type":43,"tag":439,"props":3787,"children":3788},{"style":451},[3789],{"type":49,"value":454},{"type":43,"tag":439,"props":3791,"children":3792},{"style":445},[3793],{"type":49,"value":633},{"type":43,"tag":439,"props":3795,"children":3796},{"style":451},[3797],{"type":49,"value":485},{"type":43,"tag":439,"props":3799,"children":3800},{"style":445},[3801],{"type":49,"value":3802}," doc)",{"type":43,"tag":439,"props":3804,"children":3805},{"style":451},[3806],{"type":49,"value":742},{"type":43,"tag":439,"props":3808,"children":3809},{"class":441,"line":1215},[3810],{"type":43,"tag":439,"props":3811,"children":3812},{"style":781},[3813],{"type":49,"value":3814},"\u002F\u002F User searches \"Q4 Report\" -- not found\n",{"type":43,"tag":439,"props":3816,"children":3817},{"class":441,"line":2877},[3818],{"type":43,"tag":439,"props":3819,"children":3820},{"emptyLinePlaceholder":940},[3821],{"type":49,"value":943},{"type":43,"tag":439,"props":3823,"children":3824},{"class":441,"line":2885},[3825],{"type":43,"tag":439,"props":3826,"children":3827},{"style":781},[3828],{"type":49,"value":3829},"\u002F\u002F Dangerous: publish event, query read model on next page (consumer hasn't run)\n",{"type":43,"tag":439,"props":3831,"children":3833},{"class":441,"line":3832},17,[3834,3838,3843,3847,3852,3856,3860,3865,3869,3873,3878],{"type":43,"tag":439,"props":3835,"children":3836},{"style":548},[3837],{"type":49,"value":2449},{"type":43,"tag":439,"props":3839,"children":3840},{"style":445},[3841],{"type":49,"value":3842}," eventBus",{"type":43,"tag":439,"props":3844,"children":3845},{"style":451},[3846],{"type":49,"value":454},{"type":43,"tag":439,"props":3848,"children":3849},{"style":457},[3850],{"type":49,"value":3851},"publish",{"type":43,"tag":439,"props":3853,"children":3854},{"style":445},[3855],{"type":49,"value":465},{"type":43,"tag":439,"props":3857,"children":3858},{"style":451},[3859],{"type":49,"value":470},{"type":43,"tag":439,"props":3861,"children":3862},{"style":473},[3863],{"type":49,"value":3864},"order.created",{"type":43,"tag":439,"props":3866,"children":3867},{"style":451},[3868],{"type":49,"value":470},{"type":43,"tag":439,"props":3870,"children":3871},{"style":451},[3872],{"type":49,"value":485},{"type":43,"tag":439,"props":3874,"children":3875},{"style":445},[3876],{"type":49,"value":3877}," order)",{"type":43,"tag":439,"props":3879,"children":3880},{"style":451},[3881],{"type":49,"value":742},{"type":43,"tag":439,"props":3883,"children":3885},{"class":441,"line":3884},18,[3886,3891,3895,3899,3903,3907,3912,3916,3920],{"type":43,"tag":439,"props":3887,"children":3888},{"style":445},[3889],{"type":49,"value":3890},"res",{"type":43,"tag":439,"props":3892,"children":3893},{"style":451},[3894],{"type":49,"value":454},{"type":43,"tag":439,"props":3896,"children":3897},{"style":457},[3898],{"type":49,"value":1527},{"type":43,"tag":439,"props":3900,"children":3901},{"style":445},[3902],{"type":49,"value":465},{"type":43,"tag":439,"props":3904,"children":3905},{"style":451},[3906],{"type":49,"value":470},{"type":43,"tag":439,"props":3908,"children":3909},{"style":473},[3910],{"type":49,"value":3911},"\u002Forders",{"type":43,"tag":439,"props":3913,"children":3914},{"style":451},[3915],{"type":49,"value":470},{"type":43,"tag":439,"props":3917,"children":3918},{"style":445},[3919],{"type":49,"value":516},{"type":43,"tag":439,"props":3921,"children":3922},{"style":451},[3923],{"type":49,"value":742},{"type":43,"tag":64,"props":3925,"children":3927},{"id":3926},"related-traps",[3928],{"type":49,"value":3929},"Related Traps",{"type":43,"tag":2916,"props":3931,"children":3932},{},[3933,3943,3953,3963],{"type":43,"tag":190,"props":3934,"children":3935},{},[3936,3941],{"type":43,"tag":58,"props":3937,"children":3938},{},[3939],{"type":49,"value":3940},"Race Conditions",{"type":49,"value":3942}," -- replica lag is a race condition: write to primary, read from replica, decide on stale data. Same fix: read from primary when freshness matters.",{"type":43,"tag":190,"props":3944,"children":3945},{},[3946,3951],{"type":43,"tag":58,"props":3947,"children":3948},{},[3949],{"type":49,"value":3950},"Idempotency",{"type":49,"value":3952}," -- consistency gaps make users retry (\"my save didn't work, click again\"), creating duplicates. Idempotency prevents the duplicate from causing harm.",{"type":43,"tag":190,"props":3954,"children":3955},{},[3956,3961],{"type":43,"tag":58,"props":3957,"children":3958},{},[3959],{"type":49,"value":3960},"Cache Invalidation",{"type":49,"value":3962}," -- cache staleness is a consistency problem. Write-through is the consistency-aware pattern; delete-and-repopulate races with a stale-replica refill.",{"type":43,"tag":190,"props":3964,"children":3965},{},[3966,3971],{"type":43,"tag":58,"props":3967,"children":3968},{},[3969],{"type":49,"value":3970},"Denormalization",{"type":49,"value":3972}," -- every denormalized copy is an eventually consistent read model; the gap is the window between source write and copy update.",{"type":43,"tag":3974,"props":3975,"children":3976},"style",{},[3977],{"type":49,"value":3978},"html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"items":3980,"total":4144},[3981,4000,4013,4023,4040,4055,4069,4086,4099,4111,4122,4131],{"slug":3982,"name":3982,"fn":3983,"description":3984,"org":3985,"tags":3986,"stars":3997,"repoUrl":3998,"updatedAt":3999},"trigger-authoring-chat-agent","author durable AI chat agents with Trigger.dev","Author and run a durable AI chat agent with chat.agent from @trigger.dev\u002Fsdk\u002Fai: the per-turn run loop, why you MUST spread ...chat.toStreamTextOptions() first, returning a StreamTextResult vs calling chat.pipe(), the two server actions (chat.createStartSessionAction + auth.createPublicToken), and wiring useChat to useTriggerChatTransport. Load this when building, modifying, or debugging a chat backend (the agent task or its lifecycle hooks) or its React transport, when declaring typed tools or custom data parts, or when migrating a plain AI SDK streamText route to chat.agent.\n",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[3987,3990,3993,3994],{"name":3988,"slug":3989,"type":16},"Agents","agents",{"name":3991,"slug":3992,"type":16},"SDK","sdk",{"name":9,"slug":8,"type":16},{"name":3995,"slug":3996,"type":16},"Workflow Automation","workflow-automation",14401,"https:\u002F\u002Fgithub.com\u002Ftriggerdotdev\u002Ftrigger.dev","2026-07-02T17:12:52.307135",{"slug":4001,"name":4001,"fn":4002,"description":4003,"org":4004,"tags":4005,"stars":3997,"repoUrl":3998,"updatedAt":4012},"trigger-authoring-tasks","author backend Trigger.dev tasks","Covers writing backend Trigger.dev tasks with @trigger.dev\u002Fsdk: defining task() and schemaTask(), the run function and its ctx, retries, waits, queues and concurrency, idempotency keys, run metadata, logging, triggering other tasks (and the Result shape), scheduled\u002Fcron tasks, and the essentials of trigger.config.ts. Load this whenever you are authoring or editing code inside a \u002Ftrigger directory, defining a task, or writing backend code that triggers tasks. Realtime\u002FReact hooks and AI chat are covered by separate skills.\n",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[4006,4009,4010,4011],{"name":4007,"slug":4008,"type":16},"Backend","backend",{"name":3991,"slug":3992,"type":16},{"name":9,"slug":8,"type":16},{"name":3995,"slug":3996,"type":16},"2026-07-02T17:12:48.396964",{"slug":4014,"name":4014,"fn":4015,"description":4016,"org":4017,"tags":4018,"stars":3997,"repoUrl":3998,"updatedAt":4022},"trigger-chat-agent-advanced","manage Trigger.dev chat sessions and transports","Advanced and operational chat.agent capabilities for Trigger.dev, loaded on demand. Load this when working on the raw Sessions primitive (sessions \u002F SessionHandle), a custom chat transport or the realtime wire protocol, durable sub-agents (AgentChat, chat.stream.writer), human-in-the-loop, steering, actions, background injection (chat.defer \u002F chat.inject), fast starts (preload, Head Start via @trigger.dev\u002Fsdk\u002Fchat-server), context resilience (compaction, recovery boot, OOM, large payloads), chat.local run-scoped state, offline testing with mockChatAgent, or prerelease\u002Fversion upgrades. For the everyday chat.agent({...}) definition and the useTriggerChatTransport happy path, use the trigger-authoring-chat-agent skill instead.\n",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[4019,4020,4021],{"name":3988,"slug":3989,"type":16},{"name":9,"slug":8,"type":16},{"name":3995,"slug":3996,"type":16},"2026-07-02T17:12:51.03018",{"slug":4024,"name":4024,"fn":4025,"description":4026,"org":4027,"tags":4028,"stars":3997,"repoUrl":3998,"updatedAt":4039},"trigger-realtime-and-frontend","subscribe to Trigger.dev runs in realtime","Trigger.dev client\u002Ffrontend surface: subscribe to runs in realtime (runs.subscribeToRun and the @trigger.dev\u002Freact-hooks hook useRealtimeRun), consume metadata and AI\u002Ftext streams in React (useRealtimeStream), trigger tasks from the browser (useTaskTrigger, useRealtimeTaskTrigger), and mint scoped frontend credentials with auth.createPublicToken \u002F auth.createTriggerPublicToken. Load when wiring a frontend (React\u002FNext.js\u002FRemix) or backend-for-frontend to show live run progress, status badges, token streams, trigger buttons, or wait-token approval UIs. NOT for writing the backend task itself (streams.define \u002F metadata.set is trigger-authoring-tasks territory); this is the consumer side.\n",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[4029,4032,4035,4038],{"name":4030,"slug":4031,"type":16},"Frontend","frontend",{"name":4033,"slug":4034,"type":16},"React","react",{"name":4036,"slug":4037,"type":16},"Real-time","real-time",{"name":9,"slug":8,"type":16},"2026-07-02T17:12:49.717706",{"slug":4041,"name":4041,"fn":4042,"description":4043,"org":4044,"tags":4045,"stars":4052,"repoUrl":4053,"updatedAt":4054},"trigger-agents","orchestrate AI agents with Trigger.dev","AI agent patterns with Trigger.dev - orchestration, parallelization, routing, evaluator-optimizer, and human-in-the-loop. Use when building LLM-powered tasks that need parallel workers, approval gates, tool calling, or multi-step agent workflows.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[4046,4047,4050,4051],{"name":3988,"slug":3989,"type":16},{"name":4048,"slug":4049,"type":16},"Multi-Agent","multi-agent",{"name":9,"slug":8,"type":16},{"name":3995,"slug":3996,"type":16},30,"https:\u002F\u002Fgithub.com\u002Ftriggerdotdev\u002Fskills","2026-04-06T18:54:46.023553",{"slug":4056,"name":4056,"fn":4057,"description":4058,"org":4059,"tags":4060,"stars":4052,"repoUrl":4053,"updatedAt":4068},"trigger-config","configure Trigger.dev project settings","Configure Trigger.dev projects with trigger.config.ts. Use when setting up build extensions for Prisma, Playwright, FFmpeg, Python, or customizing deployment settings.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[4061,4064,4067],{"name":4062,"slug":4063,"type":16},"Configuration","configuration",{"name":4065,"slug":4066,"type":16},"Deployment","deployment",{"name":9,"slug":8,"type":16},"2026-04-06T18:54:44.764258",{"slug":4070,"name":4070,"fn":4071,"description":4072,"org":4073,"tags":4074,"stars":4052,"repoUrl":4053,"updatedAt":4085},"trigger-cost-savings","optimize Trigger.dev task costs","Analyze Trigger.dev tasks, schedules, and runs for cost optimization opportunities. Use when asked to reduce spend, optimize costs, audit usage, right-size machines, or review task efficiency. Requires Trigger.dev MCP tools for run analysis.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[4075,4078,4081,4084],{"name":4076,"slug":4077,"type":16},"Analytics","analytics",{"name":4079,"slug":4080,"type":16},"Cost Optimization","cost-optimization",{"name":4082,"slug":4083,"type":16},"Operations","operations",{"name":9,"slug":8,"type":16},"2026-04-06T18:54:48.555552",{"slug":4087,"name":4087,"fn":4088,"description":4089,"org":4090,"tags":4091,"stars":4052,"repoUrl":4053,"updatedAt":4098},"trigger-realtime","monitor Trigger.dev tasks in real-time","Subscribe to Trigger.dev task runs in real-time from frontend and backend. Use when building progress indicators, live dashboards, streaming AI\u002FLLM responses, or React components that display task status.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[4092,4093,4096,4097],{"name":4030,"slug":4031,"type":16},{"name":4094,"slug":4095,"type":16},"Observability","observability",{"name":4036,"slug":4037,"type":16},{"name":9,"slug":8,"type":16},"2026-04-06T18:54:47.293822",{"slug":4100,"name":4100,"fn":4101,"description":4102,"org":4103,"tags":4104,"stars":4052,"repoUrl":4053,"updatedAt":4110},"trigger-setup","set up Trigger.dev in projects","Set up Trigger.dev in your project. Use when adding Trigger.dev for the first time, creating trigger.config.ts, or initializing the trigger directory.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[4105,4106,4109],{"name":4062,"slug":4063,"type":16},{"name":4107,"slug":4108,"type":16},"Local Development","local-development",{"name":9,"slug":8,"type":16},"2026-04-06T18:54:42.280816",{"slug":4112,"name":4112,"fn":4113,"description":4114,"org":4115,"tags":4116,"stars":4052,"repoUrl":4053,"updatedAt":4121},"trigger-tasks","build durable background tasks with Trigger.dev","Build AI agents, workflows and durable background tasks with Trigger.dev. Use when creating tasks, triggering jobs, handling retries, scheduling cron jobs, or implementing queues and concurrency control.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[4117,4118,4119,4120],{"name":3988,"slug":3989,"type":16},{"name":4007,"slug":4008,"type":16},{"name":9,"slug":8,"type":16},{"name":3995,"slug":3996,"type":16},"2026-04-06T18:54:43.514369",{"slug":4123,"name":4123,"fn":4124,"description":4125,"org":4126,"tags":4127,"stars":26,"repoUrl":27,"updatedAt":4130},"staff-engineering-skills-backpressure","implement backpressure in streaming pipelines","Prevent unbounded resource growth when producers outpace consumers. Use when writing producer-consumer code, queue processing, batch operations, fan-out patterns, streaming pipelines, or any code where work is generated faster than it can be processed. Activates on patterns like Promise.all on dynamic-sized arrays, unbounded in-memory queues, producer loops without depth checks, fire-and-forget async calls in loops, or any buffer between a producer and consumer without a size limit.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[4128,4129],{"name":18,"slug":19,"type":16},{"name":14,"slug":15,"type":16},"2026-06-17T08:40:42.723559",{"slug":4132,"name":4132,"fn":4133,"description":4134,"org":4135,"tags":4136,"stars":26,"repoUrl":27,"updatedAt":4143},"staff-engineering-skills-cache-invalidation","implement cache invalidation strategies","Prevent stale data bugs caused by missing or incomplete cache invalidation. Use when adding caching layers (Redis, in-memory Map, CDN, HTTP cache headers), optimizing read performance, or reviewing code that caches query results, API responses, or computed values. Activates on patterns like cache.set without cache.delete on write paths, unbounded Map\u002Fobject caches, TTL-only invalidation on security-sensitive data, Cache-Control headers on mutable content, or any caching where the write path doesn't invalidate the read cache.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[4137,4138,4141,4142],{"name":18,"slug":19,"type":16},{"name":4139,"slug":4140,"type":16},"Caching","caching",{"name":24,"slug":25,"type":16},{"name":14,"slug":15,"type":16},"2026-06-17T08:40:45.194583",26,{"items":4146,"total":2885},[4147,4152,4159,4169,4181,4188,4200],{"slug":4123,"name":4123,"fn":4124,"description":4125,"org":4148,"tags":4149,"stars":26,"repoUrl":27,"updatedAt":4130},{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[4150,4151],{"name":18,"slug":19,"type":16},{"name":14,"slug":15,"type":16},{"slug":4132,"name":4132,"fn":4133,"description":4134,"org":4153,"tags":4154,"stars":26,"repoUrl":27,"updatedAt":4143},{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[4155,4156,4157,4158],{"name":18,"slug":19,"type":16},{"name":4139,"slug":4140,"type":16},{"name":24,"slug":25,"type":16},{"name":14,"slug":15,"type":16},{"slug":4160,"name":4160,"fn":4161,"description":4162,"org":4163,"tags":4164,"stars":26,"repoUrl":27,"updatedAt":4168},"staff-engineering-skills-cardinality","prevent cardinality traps in systems code","Detect and prevent cardinality traps in systems code. Use when writing code that iterates over collections, stores items in memory, creates per-entity resources, or fans out operations across a set of items. Activates on patterns like loops over query results, in-memory Maps\u002FSets populated from databases, or \"one X per Y\" resource allocation.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[4165,4166,4167],{"name":18,"slug":19,"type":16},{"name":24,"slug":25,"type":16},{"name":14,"slug":15,"type":16},"2026-06-17T08:40:40.264608",{"slug":4170,"name":4170,"fn":4171,"description":4172,"org":4173,"tags":4174,"stars":26,"repoUrl":27,"updatedAt":4180},"staff-engineering-skills-clock-skew","prevent clock skew bugs in distributed systems","Prevent bugs caused by assuming clocks are synchronized or monotonic. Use when writing code that compares timestamps across machines, measures durations, sets lock expiry, orders distributed events, deduplicates by time window, or uses Date.now() for anything other than logging or display. Activates on patterns like Date.now() used for duration measurement, absolute timestamp expiry shared across machines, wall clock timestamps for event ordering, last-write-wins conflict resolution with timestamps, or timeout calculations using wall clock time.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[4175,4176,4179],{"name":18,"slug":19,"type":16},{"name":4177,"slug":4178,"type":16},"Debugging","debugging",{"name":24,"slug":25,"type":16},"2026-06-17T08:40:37.803541",{"slug":4,"name":4,"fn":5,"description":6,"org":4182,"tags":4183,"stars":26,"repoUrl":27,"updatedAt":28},{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[4184,4185,4186,4187],{"name":18,"slug":19,"type":16},{"name":21,"slug":22,"type":16},{"name":24,"slug":25,"type":16},{"name":14,"slug":15,"type":16},{"slug":4189,"name":4189,"fn":4190,"description":4191,"org":4192,"tags":4193,"stars":26,"repoUrl":27,"updatedAt":4199},"staff-engineering-skills-denormalization","prevent data model denormalization traps","Detect and prevent denormalization traps when designing data models. Use when writing code that copies fields between tables, embeds related data in documents, caches composed objects, or adds redundant columns to avoid joins. Activates on patterns like storing derived\u002Fcopied data, syncing fields across tables, or embedding nested objects in document stores.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[4194,4195,4198],{"name":18,"slug":19,"type":16},{"name":4196,"slug":4197,"type":16},"Data Modeling","data-modeling",{"name":21,"slug":22,"type":16},"2026-06-17T08:40:53.835868",{"slug":4201,"name":4201,"fn":4202,"description":4203,"org":4204,"tags":4205,"stars":26,"repoUrl":27,"updatedAt":4211},"staff-engineering-skills-distributed-system-fallacies","design resilient distributed systems","Prevent failures caused by treating network calls like function calls. Use when writing code that calls external services, splits a monolith into microservices, chains multiple API calls, orchestrates distributed workflows, or handles requests that depend on other services. Activates on patterns like sequential service calls without timeouts, fetch\u002Faxios calls without error handling, multi-service writes without compensation, hardcoded service URLs, or any code that assumes the network is reliable, fast, or free.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[4206,4209,4210],{"name":4207,"slug":4208,"type":16},"API Development","api-development",{"name":18,"slug":19,"type":16},{"name":24,"slug":25,"type":16},"2026-06-17T08:40:47.666795"]