Skip to main content

Module negative

Module negative 

Source
Expand description

Negative (miss) caching.

NegativeCache records keys for which a lookup has previously returned no result (a miss). Subsequent lookups can check is_known_miss to avoid hitting the origin for keys that are known to be absent.

Each miss entry is stamped with the time it was recorded and expires after a configurable TTL (in milliseconds). Expired entries are considered “unknown” again.

§Example

use oximedia_cache::negative::NegativeCache;

let mut nc = NegativeCache::new(5_000); // 5-second TTL
nc.insert_miss("missing-asset", 1_000_000);

assert!(nc.is_known_miss("missing-asset", 1_002_000)); // within TTL
assert!(!nc.is_known_miss("missing-asset", 1_006_000)); // expired

Structs§

NegativeCache
A TTL-keyed negative result cache.