Skip to main content

Store

Struct Store 

Source
pub struct Store(/* private fields */);
Expand description

存储句柄,克隆很便宜(内部是 Arc)。

Implementations§

Source§

impl Store

Source

pub fn open(cfg: Config) -> Result<Store>

Source

pub fn open_dir(dir: impl Into<PathBuf>) -> Result<Store>

用默认配置打开目录。

Source

pub fn config(&self) -> &Config

Source

pub fn cache(&self) -> Cache<'_>

Source

pub fn snapshots(&self) -> Snapshots<'_>

Source

pub fn items(&self) -> Items<'_>

Source

pub fn tasks(&self) -> Tasks<'_>

Source

pub fn stats(&self) -> Stats

Source

pub fn flush(&self) -> Result<()>

把活动段 fsync 到盘上。

Source

pub fn compact(&self) -> Result<usize>

重写所有含无效数据的段(包括当前活动段),返回重写的段数。

Source

pub fn gc(&self) -> Result<GcReport>

供 pagesift gc:超过 Config::max_bytes 时按 LRU 淘汰缓存和快照内容,然后压缩。

Source

pub async fn blocking<F, R>(&self, f: F) -> R
where F: FnOnce(&Store) -> R + Send + 'static, R: Send + 'static,

在 tokio 的阻塞线程池里调用存储,例如 store.blocking(move |s| s.cache().get(&key, max_age)).await。

Trait Implementations§

Source§

impl Clone for Store

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

Auto Trait Implementations§

§

impl Freeze for Store

§

impl RefUnwindSafe for Store

§

impl Send for Store

§

impl Sync for Store

§

impl Unpin for Store

§

impl UnsafeUnpin for Store

§

impl UnwindSafe for Store

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> Same for T

Source§

type Output = T

Should always be Self
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.