A generic abstraction layer for lightweight data storage and persistence in Swift, enabling composable caching solutions.
Shallows is a Swift library that provides a generic abstraction layer for lightweight data storage and persistence. It solves the problem of building flexible and composable caching systems by offering a core `Storage<Key, Value>` type that can be transformed and combined with other storages. It simplifies creating efficient data layers for apps, supporting in-memory, disk, and custom storage backends.
Swift developers building iOS, macOS, watchOS, or tvOS applications who need customizable caching, persistence, or data abstraction layers. It's particularly useful for those who want fine-grained control over their storage logic without heavy dependencies.
Developers choose Shallows for its minimal, composable design that avoids locking them into a specific implementation. Its powerful transformation and composition features, like zipping and error recovery, allow for building sophisticated storage solutions with minimal code, inspired by functional programming principles.
🛶 Your lightweight persistence toolbox
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Easily combine storages like memory and disk with strategies like .combined or .backed, enabling efficient caching without custom glue code, as shown in the README's composition examples.
Built-in methods for mapping keys and values support JSON, Plist, strings, and images via convenience functions, simplifying data serialization and type conversions.
Features like .fallback and .defaulting allow graceful error recovery, making storage operations more reliable, especially useful in caching scenarios with fallback values.
Strongly typed with generics in Storage<Key, Value>, ensuring compile-time safety and reducing runtime errors, which is core to its design philosophy.
The README explicitly warns that developers are responsible for thread-safety in custom storage implementations, which can lead to race conditions and increased complexity.
Only basic storages like MemoryStorage and DiskStorage are provided out-of-the-box; for advanced needs like cloud or databases, custom implementations are required.
Carthage and Cocoapods are no longer officially supported beyond version 0.10.0, forcing teams to migrate to Swift Package Manager or handle legacy issues.