Skip to main content

ArtifactCache

Struct ArtifactCache 

Source
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

Source

pub fn new() -> Self

An empty cache with the default byte budget.

Source

pub fn with_budget(budget: usize) -> Self

An empty cache with an explicit retained-byte budget.

Source

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

Source

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.

Source

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.

Source

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.

Source

pub fn len(&self) -> usize

The number of retained artifacts.

Source

pub fn is_empty(&self) -> bool

Whether the cache retains no artifact.

Source

pub fn bytes(&self) -> usize

Retained artifact bytes. Bounds the CACHE only - an artifact a Matcher still holds its own Arc to stays alive via that reference even if evicted or never cached here.

Source

pub fn stats(&self) -> (u64, u64, u64, u64)

(hits, misses, evictions, oversized_bypasses) since creation - a lifetime traffic total, NOT reset by clear(). oversized_bypasses is a built artifact whose conservative upper

Trait Implementations§

Source§

impl Default for ArtifactCache

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.