A persistent LRU cache for iOS and macOS that stores NSData with TTL, disk management, and corruption protection.
SPTPersistentCache is an open-source caching library for iOS and macOS applications that stores NSData persistently on disk with time-to-live (TTL) values and disk management semantics. It solves the problem of efficiently caching data like images and API responses while controlling disk usage and ensuring data integrity.
iOS and macOS developers who need a reliable, file-based persistent cache with TTL and garbage collection features for their apps.
Developers choose SPTPersistentCache for its battle-tested design from Spotify, robust features like TTL and corruption protection, and flexibility in managing cache size and data lifetime.
Everyone tries to implement a cache at some point in their iOS app’s lifecycle, and this is ours.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Developed and used by Spotify in production, ensuring robustness and stability for caching critical data like images and API responses.
Each cache entry includes a TTL header, allowing precise expiration management and automatic data freshness, as shown in the demo for 30-day defaults.
Includes redundancy checks in file headers to detect and handle corrupted data, enhancing data integrity for persistent storage.
Allows files to be locked to bypass TTL expiration, useful for offline content that must persist, as mentioned in Spotify's use case for cover art.
The library is written in Objective-C, requiring bridging headers in Swift projects and lacking modern Swift idioms, which may increase integration complexity.
Users must implement their own hashing functions for keys, as noted in the README, adding overhead and potential for errors in cache management.
Garbage collection is not automatic; developers must explicitly schedule it, which can lead to missed cleanups and uncontrolled disk usage if overlooked.