Skip to main content

Module cache

Module cache 

Source
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§

CacheManager
Centralized cache manager for shaping and glyph caches
CacheMetrics
Performance metrics for cache operations
CacheStats
Basic cache statistics
MultiLevelCache
Scan-resistant cache backed by Moka’s TinyLFU
RenderOutputCache
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 CacheManager instance.
get_cache_max_bytes
Get the cache byte limit from environment or use default.