Skip to main content

Module cache

Module cache 

Source
Expand description

Thread-local pattern compilation cache for ast-grep patterns.

Caches compiled ast-grep patterns to avoid redundant recompilation. Provides 5-10x speedup for repetitive pattern usage. Cache is capped at 256 entries; oldest entries are evicted when full.

Functionsยง

cache_size
Get cache statistics for monitoring.
clear_cache
Clear the pattern cache (mainly for testing).
get_or_compile_pattern
Get a compiled pattern from cache, or compile and cache it.