Skip to main content

Resizable

Trait Resizable 

Source
pub trait Resizable: Send + Sync {
    // Required methods
    fn name(&self) -> &str;
    fn current_bytes(&self) -> u64;
    fn max_bytes(&self) -> u64;
    fn set_max_bytes(&self, new: u64);
    fn stats(&self) -> ResizableStats;
}
Expand description

Minimal interface a memory-budget-aware cache must expose.

All methods are &self because caches use interior mutability (a Mutex<LruCache<...>> or a moka::sync::Cache). The budget holds Weak<dyn Resizable> handles so a dropped cache is silently removed from the next tick.

Required Methods§

Source

fn name(&self) -> &str

Human-readable label for log lines and metrics.

Source

fn current_bytes(&self) -> u64

Current bytes held by the cache.

Source

fn max_bytes(&self) -> u64

Configured soft cap. Honoured eagerly (eviction-on-insert) and at each tick by Resizable::set_max_bytes.

Source

fn set_max_bytes(&self, new: u64)

Update the soft cap. The cache may either evict synchronously (small caches) or schedule eviction over the next few ops (large caches). Either is acceptable as long as Resizable::current_bytes converges to new within one budget tick.

Source

fn stats(&self) -> ResizableStats

Stats sample used by the reapportionment policy.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§