Skip to content
LexerLangv0.2.0

Cache

lexer cache — where the parsed AST is kept and when it goes stale.

Terminal
lexer cache info  [--dir path]
lexer cache list  [--dir path]
lexer cache clear [--dir path]

What is stored#

What is stored is the parsed AST — not compiler output. LexerLang is not compiled; the cache only removes the cost of parsing the same file again on every request.

Terminal
lexer cache info --dir .

When it goes stale#

Validity is decided from the file's modification time and size. If either changed, the file is parsed again.

That is cheaper than hashing the contents, but it has a limit: if you change a file and then set its mtime back to an older value — with touch -t, or a copy that preserves mtime — the cache keeps using the stale AST.

Terminal
lexer cache clear --dir .

Where it lives#

The AST lives in memory; only metadata showing what is cached (index.json) is written to disk. The directory, in order:

Text
$LEXER_CACHE_DIR/<app>          if set, only this
<app directory>/.lexer/cache    default
~/.lexer/cache/<app>            when the app directory is read-only

In production the app directory is often read-only (root:app 0750). Then the record goes to the service user's home directory; if that fails too, the disk record is switched off and the warning is printed once. The application is not affected: the AST is still kept in memory, only the lexer cache output stays empty.

.env
# in a systemd unit, to put the record somewhere specific
Environment=LEXER_CACHE_DIR=/var/cache/app
CacheDirectory=app

Next#

Syntax — the shape of the language.