Skip to main content

QueryCache

Struct QueryCache 

Source
pub struct QueryCache<T>
where T: 'static,
{ /* private fields */ }
Expand description

应用持有、可 Clone 共享的有界数据缓存。

Implementations§

Source§

impl<T> QueryCache<T>
where T: 'static,

Source

pub fn new( limit_entries: usize, max_bytes: usize, estimate: impl Fn(&T) -> usize + 'static, ) -> Self

创建有界缓存。缓存大小以应用提供的 estimate 为准,框架不猜泛型大小。

Source

pub fn insert(&self, key: QueryKey, value: Rc<T>, group: u64)

Source

pub fn lookup(&self, key: QueryKey) -> DataCacheLookup<T>

Source

pub fn invalidate(&self, scope: InvalidationScope) -> u32

命中旧数据时只标 stale,不删除;UI 可继续展示并由 QueryStore 后台刷新。

Source

pub fn stats(&self) -> DataCacheStats

Source

pub fn take_stats(&self) -> DataCacheStats

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

pub fn clear(&self)

Trait Implementations§

Source§

impl<T> Clone for QueryCache<T>
where T: 'static,

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T> Debug for QueryCache<T>
where T: 'static,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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>
where Rc<RefCell<CacheInner<T>>>: Freeze,

§

impl<T> Move for QueryCache<T>

§

impl<T> Unpin for QueryCache<T>
where Rc<RefCell<CacheInner<T>>>: Unpin,

§

impl<T> UnsafeUnpin for QueryCache<T>
where Rc<RefCell<CacheInner<T>>>: UnsafeUnpin,

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> 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<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.