pub struct GroupValueCache { /* private fields */ }Expand description
Production-grade group value cache with TTL/LRU eviction.
Thread-safe — uses DashMap for concurrent access without global locking.
Implementations§
Source§impl GroupValueCache
impl GroupValueCache
Sourcepub fn new(config: GroupValueCacheConfig) -> Self
pub fn new(config: GroupValueCacheConfig) -> Self
Create a new cache with the given configuration.
Sourcepub fn with_defaults() -> Self
pub fn with_defaults() -> Self
Create a cache with default configuration.
Sourcepub fn is_enabled(&self) -> bool
pub fn is_enabled(&self) -> bool
Check if the cache is enabled.
Sourcepub fn config(&self) -> &GroupValueCacheConfig
pub fn config(&self) -> &GroupValueCacheConfig
Get the cache configuration.
Sourcepub fn get(&self, address: &GroupAddress) -> Option<Vec<u8>>
pub fn get(&self, address: &GroupAddress) -> Option<Vec<u8>>
Get a cached value for a group address.
Returns None if:
- Cache is disabled
- Entry does not exist
- Entry has expired (TTL exceeded)
Sourcepub fn get_entry(&self, address: &GroupAddress) -> Option<CacheEntry>
pub fn get_entry(&self, address: &GroupAddress) -> Option<CacheEntry>
Get a cached entry with full metadata.
Returns None if entry does not exist or has expired.
Sourcepub fn update(
&self,
address: GroupAddress,
value: Vec<u8>,
source: Option<String>,
update_source: UpdateSource,
)
pub fn update( &self, address: GroupAddress, value: Vec<u8>, source: Option<String>, update_source: UpdateSource, )
Update the cache with a new value.
If the cache is at capacity, performs LRU eviction before inserting.
Sourcepub fn on_indication(
&self,
address: GroupAddress,
value: Vec<u8>,
source: Option<String>,
)
pub fn on_indication( &self, address: GroupAddress, value: Vec<u8>, source: Option<String>, )
Called when an L_Data.ind indication is received.
Updates the cache entry for the target group address if the cache is enabled and auto_update_on_indication is true.
Sourcepub fn on_write(
&self,
address: GroupAddress,
value: Vec<u8>,
source: Option<String>,
)
pub fn on_write( &self, address: GroupAddress, value: Vec<u8>, source: Option<String>, )
Called when a GroupValueWrite is processed.
Updates the cache entry for the written group address.
Sourcepub fn invalidate(&self, address: &GroupAddress) -> bool
pub fn invalidate(&self, address: &GroupAddress) -> bool
Invalidate (remove) a specific cache entry.
Sourcepub fn invalidate_all(&self)
pub fn invalidate_all(&self)
Invalidate all cache entries.
Sourcepub fn purge_expired(&self) -> usize
pub fn purge_expired(&self) -> usize
Remove all expired entries.
Returns the number of entries removed.
Sourcepub fn addresses(&self) -> Vec<GroupAddress>
pub fn addresses(&self) -> Vec<GroupAddress>
Get all cached addresses.
Sourcepub fn stats_snapshot(&self) -> CacheStatsSnapshot
pub fn stats_snapshot(&self) -> CacheStatsSnapshot
Get statistics snapshot.
Sourcepub fn entry_info(&self, address: &GroupAddress) -> Option<CacheEntryInfo>
pub fn entry_info(&self, address: &GroupAddress) -> Option<CacheEntryInfo>
Get a summary of cache state for a specific address.
Sourcepub fn all_entry_info(&self) -> Vec<CacheEntryInfo>
pub fn all_entry_info(&self) -> Vec<CacheEntryInfo>
Get info for all entries.