Skip to content

miniproto.media.download.DownloadRangeCache.get_or_fetch

miniproto.media.download.DownloadRangeCache.get_or_fetch

Section titled “miniproto.media.download.DownloadRangeCache.get_or_fetch”
get_or_fetch(key: str, offset: int, limit: int, fetch: Callable[[], Awaitable[bytes]]) -> bytes

Return a cached range or await one task shared by concurrent callers.

Parameters:

  • key (str) – Stable media identity partitioning cache entries.
  • offset (int) – Exact starting byte offset of the desired range.
  • limit (int) – Exact wire request length used in the cache key.
  • fetch (Callable[[], Awaitable[bytes]]) – Async producer called once when no cache entry or pending task exists.
Cancellation Semantics

Each waiter shields the shared owner task, so cancelling one caller does not cancel the producer or other waiters. Explicit cache clearing still cancels pending producers.