{
  "id": 15778909,
  "title": "How We Built an Atomic, Sharded Incremental Cache with 57ms Rebuild Times",
  "url": "https://urgent.news/2026/10/20/how-we-built-an-atomic-sharded-incremental-cache-with-57ms-rebuild",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-10-20T18:04:41.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/vansharora21/how-we-built-an-atomic-sharded-incremental-cache-with-57ms-rebuild-times-5fb"
  },
  "original_language": "en",
  "account": "Building a fast, local-first repository intelligence engine demands speed, especially during active coding when developers anticipate immediate updates upon saving a file. To achieve this, TokenCap utilized an atomic sharded incremental cache in src/incremental/cacheManager.js. This cache architecture deviates from the traditional monolithic cache file, instead fragmenting intelligence graphs into modular JSON blocks keyed by file path hashes.\n\nTo ensure cache integrity, content-based checksums are employed, verifying cache validity through SHA-256 checksums rather than relying on volatile filesystem mtimes. A version guard mechanism is also in place, which triggers an automatic, safe cold rebuild if there's a version mismatch between the running TokenCap binary and the stored cache, preventing the use of stale schemas.\n\nScoped invalidation was another key feature, allowing TokenCap to re-parsing only the changed file (e.g., src/auth.js) and updating direct incoming and outgoing graph edges when, say, src/auth.js experiences a modification. This targeted approach significantly reduces the rebuild time.\n\nIn a benchmark test featuring 1,200 files, the cold build without cache took 1.14 seconds, while a warm full rebuild required 290 milliseconds. However, the truly impressive result was the scoped incremental build triggered by an edit in a single file. This scenario achieved an astonishing rebuild time of just 57 milliseconds. During continuous development, the VS Code extension leverages this sub-60ms rebuild capability in watch mode, automatically capturing changes after a 300ms idle period and rebuilding the incremental snapshot in mere milliseconds (57ms). This seamless process maintains the developer's typing cadence undisturbed, showcasing the efficiency of TokenCap's incremental cache implementation. The full caching solution can be explored at tokencap.vansharora.app.",
  "summary": "When building a local-first repository intelligence engine, speed is everything. A cold build on a 100k-file benchmark can take 45 to 55 seconds. But during active coding, developers expect instantaneous updates when saving a file. In TokenCap, we implemented an atomic sharded incremental cache in src/incremental/cacheManager.js . Cache Architecture and Integrity Guarantees Atomic Sharding:…",
  "key_points": [
    "TokenCap built atomic sharded incremental cache in src/incremental/cacheManager.js",
    "Cache uses content-based SHA-256 checksums for integrity verification",
    "Scoped invalidation enables 57ms rebuild time for single file edits"
  ],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}