Skip to main content

Module cache

Module cache 

Source
Expand description

缓存模块

提供内存缓存和 Redis 缓存支持。

§特性

  • 内存缓存: 基于 moka 的高性能内存缓存,支持 TinyLFU 淘汰策略
  • Redis 缓存: 支持分布式部署(需要启用 cache-redis feature)

§示例

use crates_docs::cache::{Cache, CacheConfig, create_cache};

let config = CacheConfig::default();
let cache = create_cache(&config).expect("Failed to create cache");

Modules§

memory
Memory cache implementation

Structs§

CacheConfig
缓存配置

Traits§

Cache
缓存 trait

Functions§

create_cache
创建缓存实例
default_crate_docs_ttl
默认 crate 文档 TTL(1 小时)
default_item_docs_ttl
默认项目文档 TTL(30 分钟)
default_key_prefix
默认键前缀
default_search_results_ttl
默认搜索结果 TTL(5 分钟)