pub struct CompilationCache { /* private fields */ }Expand description
Persistent compilation cache with LRU eviction
Implementations§
Source§impl CompilationCache
impl CompilationCache
Sourcepub fn new(cache_dir: Option<PathBuf>, max_size_mb: usize) -> Result<Self>
pub fn new(cache_dir: Option<PathBuf>, max_size_mb: usize) -> Result<Self>
Create a new compilation cache with LRU eviction and compression
Sourcepub fn with_compression(
cache_dir: Option<PathBuf>,
max_size_mb: usize,
use_compression: bool,
) -> Result<Self>
pub fn with_compression( cache_dir: Option<PathBuf>, max_size_mb: usize, use_compression: bool, ) -> Result<Self>
Create a new compilation cache with optional compression
Sourcepub fn default_cache_dir() -> Result<PathBuf>
pub fn default_cache_dir() -> Result<PathBuf>
Get the default cache directory
Sourcepub fn compute_hash(expr: &TLExpr, context: &CompilerContext) -> u64
pub fn compute_hash(expr: &TLExpr, context: &CompilerContext) -> u64
Compute hash for an expression and context
Sourcepub fn get(
&mut self,
expr: &TLExpr,
context: &CompilerContext,
) -> Option<EinsumGraph>
pub fn get( &mut self, expr: &TLExpr, context: &CompilerContext, ) -> Option<EinsumGraph>
Get a cached graph if available (updates LRU access time)
Sourcepub fn put(
&mut self,
expr: &TLExpr,
context: &CompilerContext,
graph: &EinsumGraph,
) -> Result<()>
pub fn put( &mut self, expr: &TLExpr, context: &CompilerContext, graph: &EinsumGraph, ) -> Result<()>
Store a compiled graph in the cache
Sourcepub fn stats(&self) -> CacheStats
pub fn stats(&self) -> CacheStats
Get cache statistics
Sourcepub fn warm_up(
&mut self,
expressions: &[(String, CompilerContext)],
) -> Result<usize>
pub fn warm_up( &mut self, expressions: &[(String, CompilerContext)], ) -> Result<usize>
Warm up the cache by precompiling a list of expressions
This is useful for frequently used expressions that should be cached on startup. Returns the number of successfully warmed expressions.
Sourcepub fn warm_up_from_file(
&mut self,
file_path: &Path,
) -> Result<CacheWarmupResult>
pub fn warm_up_from_file( &mut self, file_path: &Path, ) -> Result<CacheWarmupResult>
Warm up the cache from a file containing expressions (one per line)
Lines starting with ‘#’ are treated as comments and ignored.
Format: expression | strategy | domains
Example: AND(a, b) | soft_differentiable | Person:100,Item:50
Auto Trait Implementations§
impl Freeze for CompilationCache
impl RefUnwindSafe for CompilationCache
impl Send for CompilationCache
impl Sync for CompilationCache
impl Unpin for CompilationCache
impl UnsafeUnpin for CompilationCache
impl UnwindSafe for CompilationCache
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more