Expand description
Scan-resistant caching with TinyLFU and byte-weighted eviction
Uses Moka’s TinyLFU eviction policy to handle scan workloads gracefully. Unlike timestamp-based eviction, TinyLFU tracks access frequency and rejects one-time “scan” entries that would pollute the cache.
Byte-weighted eviction: Caches track actual memory usage, not just entry counts. A 4MB emoji bitmap consumes 4000x more quota than a 1KB glyph. This prevents memory explosions from pathological fonts.
This prevents unbounded memory growth when processing many unique fonts (e.g., font matching across hundreds of candidates).
Structs§
- Cache
Manager - Centralized cache manager for shaping and glyph caches
- Cache
Metrics - Performance metrics for cache operations
- Cache
Stats - Basic cache statistics
- Multi
Level Cache - Scan-resistant cache backed by Moka’s TinyLFU
- Render
Output Cache - Byte-weighted cache for RenderOutput values
Constants§
- DEFAULT_
CACHE_ MAX_ BYTES - Default cache byte limit: 512 MB
Functions§
- get_
cache_ manager - Returns a reference to the global
CacheManagerinstance. - get_
cache_ max_ bytes - Get the cache byte limit from environment or use default.