pub fn save_to_file(
cache: &RuleLevelCache,
identity: SnapshotIdentity,
path: &Path,
max_entries: usize,
) -> Result<usize, SnapshotError>Expand description
Write cache’s entries to path, atomically (temp file + rename)
so a concurrent reader never observes a half-written snapshot.
At most max_entries are written, taken from the MOST-recently-used
end of the cache’s LRU order. The rule cache is bounded by a memory
budget (~1/3 of a GiB by default), and a snapshot that large has no
business sitting next to a checkpoint: measured mask footprint is
~19 KB/mask at a 151,669-token vocabulary, so the cap is what keeps
the file in the tens of megabytes.
Returns the number of entries written.