pub trait CacheAble<P, T, const N: usize> {
// Required methods
fn save(&mut self, params: &[P; N], result: T);
fn fetch(&self, params: &[P; N]) -> Option<&T>;
// Provided methods
fn prepare_generation(&mut self, _scope: u64, _generation: u64) { ... }
fn save_scoped(&mut self, _scope_hash: u64, params: &[P; N], result: T) { ... }
fn fetch_scoped(&self, _scope_hash: u64, params: &[P; N]) -> Option<&T> { ... }
}Required Methods§
fn save(&mut self, params: &[P; N], result: T)
fn fetch(&self, params: &[P; N]) -> Option<&T>
Provided Methods§
Sourcefn prepare_generation(&mut self, _scope: u64, _generation: u64)
fn prepare_generation(&mut self, _scope: u64, _generation: u64)
通知缓存某 scope 进入新 generation(通常因 provider 重载)。实现可只清理该 scope。
fn save_scoped(&mut self, _scope_hash: u64, params: &[P; N], result: T)
fn fetch_scoped(&self, _scope_hash: u64, params: &[P; N]) -> Option<&T>
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".