@earth-app/collegedb
    Preparing search index...

    Function invalidateMappingCache

    • Drops cached shard mappings so the next read resolves them from KV again.

      CollegeDB caches a key's shard in memory for mappingCacheTtlMs, which makes that TTL a staleness window: a mapping changed elsewhere, by another isolate or by a KVShardMapper built directly, is not visible here until the entry expires. reassignShard already clears what it changes, so this is for changes made outside CollegeDB's own routing.

      Re-running initialize is not a substitute. It reuses the existing mapper when the bindings and options are unchanged, precisely so the cache survives the per-request initialization the Workers examples use.

      Parameters

      • Optionalkey: string

        Logical key to drop, or omit to drop every cached mapping

      Returns Promise<void>

      If CollegeDB is not initialized

      1.4.0

      const mapper = new KVShardMapper(env.KV, { hashShardMappings: true });
      await mapper.updateShardMapping('user-123', 'db-west');

      invalidateMappingCache('user-123'); // this process now reads the new shard