Skip to main content

cached

Attribute Macro cached 

Source
#[cached]
Expand description

Caches the return value of a function based on its arguments.

The cache is keyed on function name + serialized arguments using FNV-1a hashing. Cache is per-process, shared across sessions. Maximum 128 entries per function with LRU eviction (configurable).

§Requirements

  • Arguments must implement Hash + Eq + Clone
  • Return type must implement Clone

§Example

#[rustview::cached]
fn expensive_computation(n: i64) -> Vec<f64> {
    (0..n).map(|i| (i as f64).sqrt()).collect()
}