Skip to main content

Module plugin_cache

Module plugin_cache 

Source
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§

PluginCache
SQLite-backed plugin cache.
PluginDelta
Side effects captured from sourcing a plugin file.

Enums§

AliasKind

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).