Skip to main content

parse_cache_capacity

Function parse_cache_capacity 

Source
pub fn parse_cache_capacity(env_key: &str, default: usize) -> usize
Expand description

Parse an LRU cache capacity from an environment variable.

Reads env_key, parses it as usize, and returns the value clamped to a minimum of 1. Falls back to default when the variable is absent or unparseable, then also clamps the fallback to at least 1.

This helper centralises all three LRU init sites so the .max(1) guard lives in one place.