ModelCache
On-disk model cache: a directory of downloaded model files with a size budget and least-recently-used eviction.
Files are addressed by plain file names (no directories). In-progress downloads (*.part) are ignored by the size accounting. Pinned files (models currently loaded by an engine) are never evicted.
Parameters
cache directory; created on first use.
disk budget enforced by trimToSize and after touch.
epoch-millisecond clock (injectable for tests).
Constructors
Properties
Functions
Deletes abandoned *.part files (for example after the user cancels a download for good).
A download request whose destination is fileName in this cache.
Complete cached files, least recently used first.
Pins fileName so it is never evicted while the returned handle is open (for example while an engine has it loaded). Pins nest; closing a handle twice is a no-op.
Total bytes of complete cached files.
Deletes least-recently-used, unpinned files until the cache holds at most targetBytes.