Expand description
Plugin source cache — stores side effects of source/. in
SQLite.
zshrs-original infrastructure with strong C-zsh ancestry. C
zsh has bin_zcompile() (Src/parse.c) which writes a parsed
AST to a .zwc file alongside the source so subsequent reads
skip parsing. zshrs takes the idea further: rather than caching
the AST and still re-running it, we capture the side effects
(params/aliases/options/funcs set) and replay those directly —
microseconds instead of milliseconds for plugin startup. The
key/invalidation model (canonical-path + mtime) matches the
.zwc invalidation scheme C zsh uses in try_source_file()
(Src/init.c:1551).
First source: execute normally, capture state delta, write cache on worker thread. Subsequent sources: check mtime, replay cached side effects in microseconds.
Cache key: (canonical_path, mtime_secs, mtime_nsecs).
Cache invalidation: mtime mismatch → re-source, update cache.
Structs§
- Plugin
Cache - SQLite-backed plugin cache.
- Plugin
Delta - Side effects captured from sourcing a plugin file.
Enums§
Functions§
- default_
cache_ path - Default path for the plugin cache db. Honors $ZSHRS_HOME so the shell agrees with the daemon on where state lives.
- file_
mtime - Get mtime from file metadata as (secs, nsecs).