pub struct QueryCache<T>where
T: 'static,{ /* private fields */ }Expand description
应用持有、可 Clone 共享的有界数据缓存。
Implementations§
Source§impl<T> QueryCache<T>where
T: 'static,
impl<T> QueryCache<T>where
T: 'static,
Sourcepub fn new(
limit_entries: usize,
max_bytes: usize,
estimate: impl Fn(&T) -> usize + 'static,
) -> Self
pub fn new( limit_entries: usize, max_bytes: usize, estimate: impl Fn(&T) -> usize + 'static, ) -> Self
创建有界缓存。缓存大小以应用提供的 estimate 为准,框架不猜泛型大小。
pub fn insert(&self, key: QueryKey, value: Rc<T>, group: u64)
pub fn lookup(&self, key: QueryKey) -> DataCacheLookup<T>
Sourcepub fn invalidate(&self, scope: InvalidationScope) -> u32
pub fn invalidate(&self, scope: InvalidationScope) -> u32
命中旧数据时只标 stale,不删除;UI 可继续展示并由 QueryStore 后台刷新。
pub fn stats(&self) -> DataCacheStats
pub fn take_stats(&self) -> DataCacheStats
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn clear(&self)
Trait Implementations§
Source§impl<T> Clone for QueryCache<T>where
T: 'static,
impl<T> Clone for QueryCache<T>where
T: 'static,
Auto Trait Implementations§
impl<T> !RefUnwindSafe for QueryCache<T>
impl<T> !Send for QueryCache<T>
impl<T> !Sync for QueryCache<T>
impl<T> !UnwindSafe for QueryCache<T>
impl<T> Forget for QueryCache<T>
impl<T> Freeze for QueryCache<T>
impl<T> Move for QueryCache<T>
impl<T> Unpin for QueryCache<T>
impl<T> UnsafeUnpin for QueryCache<T>
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