Avoid expensive clones in `get` using `Arc`
v0.11.xBecause mini_moka::sync::Cache::get returns a clone of the value (Option<V>) rather than a reference (Option<&V>), retrieving large or expensive-to-clone values can impact performance.
To mitigate this, wrap your values in std::sync::Arc. Cloning an Arc is a cheap operation that only increments a reference count, rather than copying the underlying data.
use std::sync::Arc;
use mini_moka::sync::Cache;
let cache: Cache<usize, Arc<Vec<u8>>> = Cache::new(100);
let large_value = vec![0u8; 2 * 1024 * 1024]; // 2 MiB
// Wrap in Arc before inserting
cache.insert(1, Arc::new(large_value));
// get() will call Arc::clone(), which is very fast
let retrieved = cache.get(&1);