Overview
src/services/imageCache.ts caches downloaded images to the file system via expo-file-system without enforcing a total size limit. Heavy course browsing accumulates hundreds of megabytes in the app cache directory, triggering OS-level storage warnings and unexpected cache eviction behavior.
Specifications
Features:
- Image cache enforces 100MB maximum size
- When 80% full, least-recently-used images evicted automatically
- Cache size exposed as metric in
memoryPressureService
- Cache cleared on
memoryPressureService critical event
Tasks:
- Add LRU eviction to
imageCache.ts with MAX_CACHE_SIZE_BYTES = 100 * 1024 * 1024
- Track total cached bytes and access timestamps per entry
- Implement
evictLRU(targetBytesToFree: number) method
- Subscribe
imageCache.clearNonCritical() to memoryPressureService critical event
- Add unit test confirming eviction fires at 80MB when 81st MB pushed
Impacted Files:
src/services/imageCache.ts
src/components/common/CachedImage.tsx
Acceptance Criteria
- Image cache does not exceed 100MB on disk
- LRU eviction fires when cache reaches 80MB
- Critical memory pressure clears all non-pinned cached images
- Unit test confirms eviction at 80% threshold
Overview
src/services/imageCache.tscaches downloaded images to the file system viaexpo-file-systemwithout enforcing a total size limit. Heavy course browsing accumulates hundreds of megabytes in the app cache directory, triggering OS-level storage warnings and unexpected cache eviction behavior.Specifications
Features:
memoryPressureServicememoryPressureServicecritical eventTasks:
imageCache.tswithMAX_CACHE_SIZE_BYTES = 100 * 1024 * 1024evictLRU(targetBytesToFree: number)methodimageCache.clearNonCritical()tomemoryPressureServicecritical eventImpacted Files:
src/services/imageCache.tssrc/components/common/CachedImage.tsxAcceptance Criteria