Evict a cached local-path entry whose on-disk cache no longer matches its files. Skipped while inside the cooldown window so repos that are slow to build aren't rebuilt faster than they can be served.
(self, source: str, cache_key: str)
| 218 | self._revalidate_after.pop(cache_key, None) |
| 219 | |
| 220 | async def _evict_if_stale(self, source: str, cache_key: str) -> None: |
| 221 | """Evict a cached local-path entry whose on-disk cache no longer matches its files. |
| 222 | |
| 223 | Skipped while inside the cooldown window so repos that are slow to build aren't |
| 224 | rebuilt faster than they can be served. |
| 225 | """ |
| 226 | cached = self._tasks.get(cache_key) |
| 227 | if ( |
| 228 | cached is None |
| 229 | or is_git_url(source) |
| 230 | or not cached.done() |
| 231 | or cached.cancelled() |
| 232 | or cached.exception() is not None |
| 233 | ): |
| 234 | return |
| 235 | if time.monotonic() < self._revalidate_after.get(cache_key, 0.0): |
| 236 | return |
| 237 | validated = await asyncio.to_thread(get_validated_cache, cache_key, self._model_path, self._content) |
| 238 | # Only evict if this entry hasn't already been replaced by a concurrent caller. |
| 239 | if validated is None and self._tasks.get(cache_key) is cached: |
| 240 | self.evict(source) |
| 241 | |
| 242 | async def get(self, source: str, ref: str | None = None) -> SembleIndex: |
| 243 | """Return an index for the requested source, building and caching it on first access. |