pub struct ArtifactCache { /* private fields */ }Expand description
A thread-safe, byte-bounded cache of compiled artifacts keyed by [ArtifactKey]. Read-mostly
after warm-up; once the budget is reached, further artifacts are built and returned but not
Implementations§
Source§impl ArtifactCache
impl ArtifactCache
Sourcepub fn with_budget(budget: usize) -> Self
pub fn with_budget(budget: usize) -> Self
An empty cache with an explicit retained-byte budget.
Sourcepub fn get_or_build_json_schema(
&self,
schema: &str,
assume_closed: bool,
vocab_fingerprint: VocabFingerprint,
mask_vocab_size: usize,
bind_mode: BindMode,
build: impl FnOnce() -> Result<CompiledArtifact, CompileError>,
) -> Result<Arc<CompiledArtifact>, CompileError>
pub fn get_or_build_json_schema( &self, schema: &str, assume_closed: bool, vocab_fingerprint: VocabFingerprint, mask_vocab_size: usize, bind_mode: BindMode, build: impl FnOnce() -> Result<CompiledArtifact, CompileError>, ) -> Result<Arc<CompiledArtifact>, CompileError>
The cached artifact for the exact JSON Schema text and options, calling build and
inserting its result on a miss. The key is derived from schema/assume_closed INSIDE this
Sourcepub fn get_or_build_mfir_wire(
&self,
wire: &[u8],
vocab_fingerprint: VocabFingerprint,
mask_vocab_size: usize,
bind_mode: BindMode,
build: impl FnOnce() -> Result<CompiledArtifact, CompileError>,
) -> Result<Arc<CompiledArtifact>, CompileError>
pub fn get_or_build_mfir_wire( &self, wire: &[u8], vocab_fingerprint: VocabFingerprint, mask_vocab_size: usize, bind_mode: BindMode, build: impl FnOnce() -> Result<CompiledArtifact, CompileError>, ) -> Result<Arc<CompiledArtifact>, CompileError>
Same contract as Self::get_or_build_json_schema, keyed on the exact MFIR wire bytes
instead of schema text.
Sourcepub fn get_or_build_executable(
&self,
semantic_identity: &[u8],
vocab_fingerprint: VocabFingerprint,
mask_vocab_size: usize,
bind_mode: BindMode,
build: impl FnOnce() -> Result<CompiledArtifact, CompileError>,
) -> Result<Arc<CompiledArtifact>, CompileError>
pub fn get_or_build_executable( &self, semantic_identity: &[u8], vocab_fingerprint: VocabFingerprint, mask_vocab_size: usize, bind_mode: BindMode, build: impl FnOnce() -> Result<CompiledArtifact, CompileError>, ) -> Result<Arc<CompiledArtifact>, CompileError>
Returns or binds one exact vocabulary-neutral executable identity.
Sourcepub fn clear(&self)
pub fn clear(&self)
Drops every retained artifact. Also clears the LRU touch-log. Traffic counters (stats())
are NOT reset - they are a lifetime total, not scoped to content currently retained.