pub struct CacheInvalidator<K> { /* private fields */ }Expand description
Tracks dependencies between cache keys and supports cascade invalidation.
When key A depends on key B, invalidating B also invalidates A.
Implementations§
Source§impl<K> CacheInvalidator<K>
impl<K> CacheInvalidator<K>
Sourcepub fn add_dependency(&self, dependency: K, dependent: K)
pub fn add_dependency(&self, dependency: K, dependent: K)
Register that dependent depends on dependency.
When dependency is invalidated, dependent will also be invalidated.
Sourcepub fn remove_dependency(&self, dependency: &K, dependent: &K)
pub fn remove_dependency(&self, dependency: &K, dependent: &K)
Remove a specific dependency relationship.
Sourcepub fn cascade(&self, root: &K) -> InvalidationResult<K>
pub fn cascade(&self, root: &K) -> InvalidationResult<K>
Compute the full set of keys that should be invalidated when root is
invalidated, following the dependency graph transitively.
Sourcepub fn dependency_count(&self) -> usize
pub fn dependency_count(&self) -> usize
Number of keys that have dependents registered.
Sourcepub fn has_dependents(&self, key: &K) -> bool
pub fn has_dependents(&self, key: &K) -> bool
Check if a key has any dependents.
Trait Implementations§
Auto Trait Implementations§
impl<K> !Freeze for CacheInvalidator<K>
impl<K> RefUnwindSafe for CacheInvalidator<K>
impl<K> Send for CacheInvalidator<K>where
K: Send,
impl<K> Sync for CacheInvalidator<K>
impl<K> Unpin for CacheInvalidator<K>where
K: Unpin,
impl<K> UnsafeUnpin for CacheInvalidator<K>
impl<K> UnwindSafe for CacheInvalidator<K>
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
Mutably borrows from an owned value. Read more