Caching
Lūn uses a cache to avoid re-running tools on files that haven’t changed. By
default, the cache is stored in .lun/cache in the project root. lun cache
can be used to manage the cache. The cache is automatically kept below a (small)
maximum size.
Keys
There are two kinds of cache entry. They both include the following:
- File path
- File metadata, including size, owner UID and GID, and permissions (mode)
- Tool command line
- Tool working directory, if specified
- Metadata of the tool configuration file(s), if specified
- Names and content of relevant environment variables1
- Output of the tool’s
--versionflag (if--carefulis used)
mtime entries also include the file modification time.
Content entries also include the hash of the file content.
Caching strategy
Essentially, Lūn operates with three “levels” of cache. From fastest to slowest:
mtimeentries (enabled by default, can be disabled with--no-mtimeormtime = false)- content entries
- Git information (disabled by default, can be enabled with
--refsorrefs = [...])
For each (file, tool) pair, Lūn queries the caches from fastest to slowest. If any return a hit, the pair is skipped. Also, in the case that a faster cache does not have a hit but a slower one does, Lūn will update the faster caches so that they return a hit next time.
In detail, for each (file, tool) pair, Lūn does the following:
- If
mtimeis enabled, Lūn first checks if there is anmtimecache entry for the pair. If so, it skips the pair. - Otherwise, Lūn checks for a content entry. If present, it saves an
mtimeentry and skips the pair. - Otherwise, if
refsare enabled, Lūn checks to see if the file is unchanged from any of those refs. If so, it saves an content entry and anmtimeentry and skips the pair. - Otherwise, Lūn runs the tool on the file (possibly in a batch with other files).
- If successful, it saves a content entry for the pair. If
mtimeis enabled, it also saves anmtimeentry.
-
Variables that start with
EXE_whereEXEis the upper-cased version of the name of the tool binary. ↩