Byte-capacity LRU cache that fetches each chunk only once
I was asked this
No reports yet. Sign in to say where you were asked it.
Build a cache for chunks of container images pulled over the network, with a capacity measured in bytes. A get(key, size) is a hit when the chunk is cached (refresh its recency), waits when the same chunk is already being fetched (don't start a second download), and otherwise starts one fetch. When a fetch finishes, store the chunk, evicting least recently used chunks until it fits; a chunk bigger than the whole cache is not stored. Only finished chunks take up space. Report which chunks each insert evicts, and talk about how this maps to real concurrent callers.
No official answer yet. Write yours on the right and run it.
Nothing published yet.
Sign in to submit your code; every attempt is kept here.
