Grab's Android team evolved their image disk cache from a standard LRU to a Time-Aware LRU (TLRU) to reclaim storage across millions of devices. The standard Glide DiskLruCache had no time-based eviction, leaving stale promotional and feature images on disk indefinitely. TLRU adds three core attributes: a TTL (20 days) to expire old entries, a minimum cache size threshold (20 MB) to protect essential images for returning users, and the inherited maximum size limit (100 MB). Implementation involved cloning Glide's DiskLruCache, extending the journal file format to persist last-access timestamps, and adding time-based eviction logic that leverages LRU ordering for efficiency. A backward-compatible migration strategy avoided cache invalidation for existing users. After full rollout, P95 app storage dropped by ~50 MB with cache hit ratio staying within a 3 percentage point threshold, reclaiming terabytes of storage across 100M+ installs.
Table of contents
IntroductionUnderstanding LRU cache limitationsThe challengeTLRU cache: The solutionTechnical implementationFinding optimal configuration valuesImpact and resultsConclusionJoin UsSort: