pub struct ServiceConfigCache { /* private fields */ }Expand description
Thread-safe cache for service configurations
Caches aggregation configs, operator weights, and operator lists with TTL-based expiration.
Implementations§
Source§impl ServiceConfigCache
impl ServiceConfigCache
Sourcepub fn with_default_ttl() -> Self
pub fn with_default_ttl() -> Self
Create a new cache with default TTL (5 minutes)
Sourcepub fn set_ttl(&mut self, ttl: Duration)
pub fn set_ttl(&mut self, ttl: Duration)
Set a new TTL (does not affect already cached entries)
Sourcepub async fn get_aggregation_config(
&self,
client: &TangleClient,
service_id: u64,
job_index: u8,
) -> Result<AggregationConfig, CacheError>
pub async fn get_aggregation_config( &self, client: &TangleClient, service_id: u64, job_index: u8, ) -> Result<AggregationConfig, CacheError>
Get aggregation config, using cache if available and not expired
Sourcepub fn set_aggregation_config(
&self,
service_id: u64,
job_index: u8,
config: AggregationConfig,
) -> Result<(), CacheError>
pub fn set_aggregation_config( &self, service_id: u64, job_index: u8, config: AggregationConfig, ) -> Result<(), CacheError>
Pre-populate aggregation config cache
Sourcepub async fn get_operator_weights(
&self,
client: &TangleClient,
service_id: u64,
) -> Result<OperatorWeights, CacheError>
pub async fn get_operator_weights( &self, client: &TangleClient, service_id: u64, ) -> Result<OperatorWeights, CacheError>
Get operator weights for a service, using cache if available
Sourcepub fn set_operator_weights(
&self,
service_id: u64,
weights: OperatorWeights,
) -> Result<(), CacheError>
pub fn set_operator_weights( &self, service_id: u64, weights: OperatorWeights, ) -> Result<(), CacheError>
Pre-populate operator weights cache
Sourcepub async fn get_service_operators(
&self,
client: &TangleClient,
service_id: u64,
) -> Result<ServiceOperators, CacheError>
pub async fn get_service_operators( &self, client: &TangleClient, service_id: u64, ) -> Result<ServiceOperators, CacheError>
Get service operators list, using cache if available
Sourcepub async fn get_operator_metadata(
&self,
client: &TangleClient,
blueprint_id: u64,
operator: Address,
) -> Result<OperatorMetadata, CacheError>
pub async fn get_operator_metadata( &self, client: &TangleClient, blueprint_id: u64, operator: Address, ) -> Result<OperatorMetadata, CacheError>
Get metadata for a specific operator (cached by blueprint + operator)
Sourcepub async fn get_service_operator_metadata(
&self,
client: &TangleClient,
blueprint_id: u64,
service_id: u64,
) -> Result<HashMap<Address, OperatorMetadata>, CacheError>
pub async fn get_service_operator_metadata( &self, client: &TangleClient, blueprint_id: u64, service_id: u64, ) -> Result<HashMap<Address, OperatorMetadata>, CacheError>
Get metadata for all operators in a service.
Sourcepub fn invalidate_service(&self, service_id: u64)
pub fn invalidate_service(&self, service_id: u64)
Invalidate all cached data for a specific service
Sourcepub fn invalidate_aggregation_config(&self, service_id: u64, job_index: u8)
pub fn invalidate_aggregation_config(&self, service_id: u64, job_index: u8)
Invalidate a specific aggregation config
Sourcepub fn cleanup_expired(&self)
pub fn cleanup_expired(&self)
Remove expired entries from all caches
Sourcepub fn stats(&self) -> CacheStats
pub fn stats(&self) -> CacheStats
Get cache statistics
Source§impl ServiceConfigCache
impl ServiceConfigCache
Sourcepub fn handle_event(&self, event: &CacheInvalidationEvent)
pub fn handle_event(&self, event: &CacheInvalidationEvent)
Handle a cache invalidation event
Call this when you receive relevant on-chain events to keep the cache in sync. Logs clearly when invalidation occurs.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for ServiceConfigCache
impl RefUnwindSafe for ServiceConfigCache
impl Send for ServiceConfigCache
impl Sync for ServiceConfigCache
impl Unpin for ServiceConfigCache
impl UnsafeUnpin for ServiceConfigCache
impl UnwindSafe for ServiceConfigCache
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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