A Swift caching library with hybrid memory/disk storage, type-safe Codable support, and extensive configuration options.
Cache is a Swift caching library that provides hybrid memory and disk storage for iOS, tvOS, and macOS apps. It solves the problem of efficiently persisting and retrieving data by leveraging Swift's Codable protocol for seamless serialization and offering extensive configuration options. The library is thread-safe and supports both synchronous and asynchronous operations.
iOS, tvOS, and macOS developers who need a robust, type-safe caching solution for persisting Codable objects, network responses, or other application data.
Developers choose Cache for its focused design, excellent Codable integration, and flexible hybrid storage model. It avoids bloat while providing powerful features like expiry management, observation, and comprehensive error handling.
:package: Nothing but Cache.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Leverages Swift's Codable protocol for compile-time type checking and seamless serialization of custom objects, as demonstrated with the User struct example, ensuring data integrity.
Combines fast in-memory access with persistent disk storage, configurable via DiskConfig and MemoryConfig for expiry policies and size limits, offering flexibility for different use cases.
Provides both synchronous and asynchronous APIs, including Swift Concurrency, ensuring safe concurrent access and non-blocking operations, with examples in the README for async workflows.
Allows observing changes at storage or key levels with automatic observer lifecycle management, useful for real-time UI updates without manual cleanup.
Limited to iOS, tvOS, and macOS, making it unsuitable for cross-platform or server-side Swift projects, which restricts its use in broader ecosystems.
Requires explicit try-catch blocks for error management with StorageError enums, adding verbosity compared to libraries with more fluent or automatic error handling.
Configuration with DiskConfig and MemoryConfig can be overkill for simple caching needs, and dependencies like SwiftHash for Carthage add extra setup steps.