Skip to main content

default_cache

Function default_cache 

Source
pub fn default_cache() -> &'static Cache
Expand description

获取全局 Cache facade 实例

对齐 PHP Cache::set/get/delete/... 静态调用方式。

§注意

首次调用会创建一个空的 Cache(未注册任何驱动)。调用方需先调用 Cache::init_default 注册默认驱动后再使用。

§示例

use sz_rust_cache_facade::{Cache, MemoryCacheDriver};

Cache::init_default(MemoryCacheDriver::new());
Cache::default().set("key", "value", None).unwrap();