Cache

Trait Cache 

pub trait Cache: Sized {
    // Required methods
    fn with_cache_capacity(self, size: u64) -> Self;
    fn enable_cache(self) -> Self;
    fn clear_cache(&self);
    fn disable_cache(self) -> Self;
}
Expand description

Trait for enabling prediction caching on equation types.

Caching is enabled by default with a capacity of 100,000 entries. Use these methods to adjust capacity, clear entries, or disable caching.

§Example

use pharmsol::*;

// Caching is on by default:
let ode = ODE::new(diffeq, lag, fa, init, out);

// Adjust capacity:
let ode = ODE::new(diffeq, lag, fa, init, out)
    .with_cache_capacity(50_000);

// Disable caching:
let ode = ODE::new(diffeq, lag, fa, init, out)
    .disable_cache();

Required Methods§

fn with_cache_capacity(self, size: u64) -> Self

Enable caching with the given maximum number of entries.

When caching is enabled, results for the same inputs are stored and reused. Cloned equations share the same cache.

If caching is already enabled, this replaces the cache with a new, empty one of the given size — all previously cached entries are discarded.

fn enable_cache(self) -> Self

Enable caching with the default size (100,000 entries).

If caching is already enabled, this replaces the cache with a new, empty one — all previously cached entries are discarded.

fn clear_cache(&self)

Clear all entries from this equation’s cache, if caching is enabled.

The cache itself remains active (with the same capacity). Does nothing if caching is not enabled.

fn disable_cache(self) -> Self

Disable caching.

Disables caching and discards all cached entries.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

§

impl Cache for Analytical

§

impl Cache for ODE

§

impl Cache for SDE