Skip to main content

Cache

Struct Cache 

Source
pub struct Cache<'a> { /* private fields */ }

Implementations§

Source§

impl<'a> Cache<'a>

Source

pub fn entry(&self, key: impl AsRef<[u8]>) -> Result<Option<CacheEntry>>

读出缓存条目,不看年龄。

Source

pub fn get( &self, key: impl AsRef<[u8]>, max_age: Duration, ) -> Result<Option<CacheEntry>>

maxAge 语义:年龄小于 max_age 才返回;max_age 为 0 时总是 None。

Source

pub fn get_at( &self, key: impl AsRef<[u8]>, max_age: Duration, now: SystemTime, ) -> Result<Option<CacheEntry>>

Source

pub fn get_min_age( &self, key: impl AsRef<[u8]>, min_age: Duration, now: SystemTime, ) -> Result<Option<CacheEntry>>

minAge 语义:年龄不小于 min_age 才返回。

Source

pub fn lookup( &self, key: impl AsRef<[u8]>, policy: &CachePolicy, ) -> Result<CacheLookup>

按一次请求的参数查缓存。设置了 min_age 时忽略 max_age(Firecrawl 文档里 minAge 模式只查缓存,没有说明和 maxAge 的组合)。

Source

pub fn put(&self, key: impl AsRef<[u8]>, value: &[u8]) -> Result<()>

Source

pub fn put_at( &self, key: impl AsRef<[u8]>, value: &[u8], stored_at: SystemTime, ) -> Result<()>

指定写入时间(导入旧数据、测试)。

Source

pub fn store( &self, key: impl AsRef<[u8]>, value: &[u8], policy: &CachePolicy, ) -> Result<bool>

按 store_in_cache 决定是否写入,返回是否写了。

Source

pub fn remove(&self, key: impl AsRef<[u8]>) -> Result<bool>

Auto Trait Implementations§

§

impl<'a> Freeze for Cache<'a>

§

impl<'a> RefUnwindSafe for Cache<'a>

§

impl<'a> Send for Cache<'a>

§

impl<'a> Sync for Cache<'a>

§

impl<'a> Unpin for Cache<'a>

§

impl<'a> UnsafeUnpin for Cache<'a>

§

impl<'a> UnwindSafe for Cache<'a>

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> 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, 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.