pub struct DocCache { /* private fields */ }Expand description
Implementations§
Source§impl DocCache
impl DocCache
Sourcepub fn with_ttl(cache: Arc<dyn Cache>, ttl: DocCacheTtl) -> Self
pub fn with_ttl(cache: Arc<dyn Cache>, ttl: DocCacheTtl) -> Self
创建新的文档缓存(使用自定义 TTL)
§参数
cache- 缓存实例ttl- TTL 配置
§示例
use std::sync::Arc;
use crates_docs::tools::docs::cache::{DocCache, DocCacheTtl};
use crates_docs::cache::memory::MemoryCache;
let cache = Arc::new(MemoryCache::new(1000));
let ttl = DocCacheTtl {
crate_docs_secs: 7200,
search_results_secs: 600,
item_docs_secs: 3600,
jitter_ratio: 0.1,
};
let doc_cache = DocCache::with_ttl(cache, ttl);Sourcepub async fn get_crate_docs(
&self,
crate_name: &str,
version: Option<&str>,
) -> Option<String>
pub async fn get_crate_docs( &self, crate_name: &str, version: Option<&str>, ) -> Option<String>
Sourcepub async fn set_crate_docs(
&self,
crate_name: &str,
version: Option<&str>,
content: String,
) -> Result<()>
pub async fn set_crate_docs( &self, crate_name: &str, version: Option<&str>, content: String, ) -> Result<()>
Sourcepub async fn set_search_results(
&self,
query: &str,
limit: u32,
content: String,
) -> Result<()>
pub async fn set_search_results( &self, query: &str, limit: u32, content: String, ) -> Result<()>
Sourcepub async fn get_item_docs(
&self,
crate_name: &str,
item_path: &str,
version: Option<&str>,
) -> Option<String>
pub async fn get_item_docs( &self, crate_name: &str, item_path: &str, version: Option<&str>, ) -> Option<String>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for DocCache
impl !RefUnwindSafe for DocCache
impl Send for DocCache
impl Sync for DocCache
impl Unpin for DocCache
impl UnsafeUnpin for DocCache
impl !UnwindSafe for DocCache
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