Every re_*() function compiles a character pattern through a cache of
recently used compiled patterns, so a pattern used again, in a loop or
across calls, is not recompiled. Patterns are keyed by their text,
flags, dialect, literal and jit. The least recently used pattern
is dropped when the cache is full. Patterns longer than 65,536 characters
are never cached.
Value
re_cache_size() returns the capacity; when setting it, the
previous capacity, invisibly. re_cache_clear() returns the number of
patterns it dropped, invisibly.
Details
re objects from re_compile() stay valid when the cache drops their
pattern or is cleared.