CacheManager

Struct CacheManager 

Source
pub struct CacheManager { /* private fields */ }
Expand description

Multi-level caching system for embeddings and computations

Implementations§

Source§

impl CacheManager

Source

pub fn new(config: CacheConfig) -> Self

Create a new cache manager

Source

pub async fn start(&mut self) -> Result<()>

Start the cache manager with background tasks

Source

pub async fn stop(&mut self)

Stop the cache manager

Source

pub fn get_embedding(&self, entity: &str) -> Option<Vector>

Get cached embedding

Source

pub fn put_embedding(&self, entity: String, embedding: Vector)

Cache an embedding

Source

pub fn get_computation(&self, key: &ComputationKey) -> Option<ComputationResult>

Get cached computation result

Source

pub fn put_computation( &self, key: ComputationKey, result: ComputationResult, computation_time_us: u64, )

Cache a computation result

Source

pub fn get_similarity_cache(&self, query: &str) -> Option<Vec<(String, f64)>>

Get cached similarity results

Source

pub fn put_similarity_cache(&self, query: String, results: Vec<(String, f64)>)

Cache similarity results

Source

pub async fn warm_cache( &self, model: &dyn EmbeddingModel, entities: Vec<String>, ) -> Result<usize>

Warm up cache with frequently accessed entities

Source

pub async fn precompute_common_operations( &self, model: &dyn EmbeddingModel, common_queries: Vec<(String, String)>, ) -> Result<usize>

Precompute and cache common operations

Source

pub fn get_stats(&self) -> CacheStats

Get cache statistics

Source

pub fn clear_all(&self)

Clear all caches

Source

pub fn estimate_memory_usage(&self) -> usize

Get memory usage estimation

Source

pub fn cache_attention_weights( &self, layer_id: &str, input_hash: &str, model_id: Uuid, attention_weights: Vec<f64>, computation_time_us: u64, )

Cache attention weights for a specific layer and input

Source

pub fn get_attention_weights( &self, layer_id: &str, input_hash: &str, model_id: Uuid, ) -> Option<Vec<f64>>

Get cached attention weights

Source

pub fn cache_intermediate_activations( &self, layer_id: &str, input_hash: &str, model_id: Uuid, activations: Vec<f64>, computation_time_us: u64, )

Cache intermediate activations for a specific layer and input

Source

pub fn get_intermediate_activations( &self, layer_id: &str, input_hash: &str, model_id: Uuid, ) -> Option<Vec<f64>>

Get cached intermediate activations

Source

pub fn cache_gradients( &self, layer_id: &str, batch_hash: &str, model_id: Uuid, gradients: Vec<Vec<f64>>, computation_time_us: u64, )

Cache gradients for training optimization

Source

pub fn get_gradients( &self, layer_id: &str, batch_hash: &str, model_id: Uuid, ) -> Option<Vec<Vec<f64>>>

Get cached gradients

Source

pub fn cache_model_weights( &self, model_name: &str, checkpoint: &str, model_id: Uuid, weights: Vec<Vec<f64>>, computation_time_us: u64, )

Cache model weights for quick model switching

Source

pub fn get_model_weights( &self, model_name: &str, checkpoint: &str, model_id: Uuid, ) -> Option<Vec<Vec<f64>>>

Get cached model weights

Source

pub fn cache_feature_vectors( &self, task_name: &str, input_hash: &str, model_id: Uuid, features: Vec<f64>, computation_time_us: u64, )

Cache feature vectors for downstream tasks

Source

pub fn get_feature_vectors( &self, task_name: &str, input_hash: &str, model_id: Uuid, ) -> Option<Vec<f64>>

Get cached feature vectors

Source

pub fn cache_embedding_matrices( &self, operation: &str, batch_hash: &str, model_id: Uuid, matrices: Vec<Vec<f64>>, computation_time_us: u64, )

Cache embedding matrices for batch operations

Source

pub fn get_embedding_matrices( &self, operation: &str, batch_hash: &str, model_id: Uuid, ) -> Option<Vec<Vec<f64>>>

Get cached embedding matrices

Source

pub fn cache_loss_values( &self, loss_type: &str, epoch_batch: &str, model_id: Uuid, losses: Vec<f64>, computation_time_us: u64, )

Cache loss values for training monitoring

Source

pub fn get_loss_values( &self, loss_type: &str, epoch_batch: &str, model_id: Uuid, ) -> Option<Vec<f64>>

Get cached loss values

Source

pub fn cache_generic_result( &self, operation: &str, input_hash: &str, model_id: Uuid, result: Vec<f64>, computation_time_us: u64, )

Cache generic computation results for extensibility

Source

pub fn get_generic_result( &self, operation: &str, input_hash: &str, model_id: Uuid, ) -> Option<Vec<f64>>

Get cached generic result

Source

pub fn clear_computation_cache(&self, operation_prefix: &str) -> usize

Clear cache for specific computation type

Source

pub fn get_cache_hit_rates(&self) -> HashMap<String, f64>

Get cache hit rates by computation type

Source

pub fn adaptive_resize(&mut self)

Adaptive cache resizing based on usage patterns

Source

pub fn batch_cache_computations( &self, computations: Vec<(ComputationKey, ComputationResult)>, )

Batch cache multiple computation results efficiently

Source

pub fn get_computation_type_stats(&self) -> HashMap<String, (u64, u64)>

Get cache efficiency metrics for different computation types

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> Az for T

Source§

fn az<Dst>(self) -> Dst
where T: Cast<Dst>,

Casts the value.
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<Src, Dst> CastFrom<Src> for Dst
where Src: Cast<Dst>,

Source§

fn cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> CheckedAs for T

Source§

fn checked_as<Dst>(self) -> Option<Dst>
where T: CheckedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> CheckedCastFrom<Src> for Dst
where Src: CheckedCast<Dst>,

Source§

fn checked_cast_from(src: Src) -> Option<Dst>

Casts the value.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> OverflowingAs for T

Source§

fn overflowing_as<Dst>(self) -> (Dst, bool)
where T: OverflowingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> OverflowingCastFrom<Src> for Dst
where Src: OverflowingCast<Dst>,

Source§

fn overflowing_cast_from(src: Src) -> (Dst, bool)

Casts the value.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> SaturatingAs for T

Source§

fn saturating_as<Dst>(self) -> Dst
where T: SaturatingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> SaturatingCastFrom<Src> for Dst
where Src: SaturatingCast<Dst>,

Source§

fn saturating_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> StrictAs for T

Source§

fn strict_as<Dst>(self) -> Dst
where T: StrictCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> StrictCastFrom<Src> for Dst
where Src: StrictCast<Dst>,

Source§

fn strict_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<T> UnwrappedAs for T

Source§

fn unwrapped_as<Dst>(self) -> Dst
where T: UnwrappedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> UnwrappedCastFrom<Src> for Dst
where Src: UnwrappedCast<Dst>,

Source§

fn unwrapped_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> WrappingAs for T

Source§

fn wrapping_as<Dst>(self) -> Dst
where T: WrappingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> WrappingCastFrom<Src> for Dst
where Src: WrappingCast<Dst>,

Source§

fn wrapping_cast_from(src: Src) -> Dst

Casts the value.