Hello everyone,
I have released Yashima 1.0, an open-source Swift package for caching locally generated app artifacts.
Many apps repeatedly regenerate the same thumbnails, map snapshots, chart images, rendered documents, summaries, or derived metadata while scrolling, navigating, relaunching, or revisiting content. These values are safe to recreate, but recreating them every time is unnecessary work.
Yashima gives that workflow a small async get-or-generate API:
let thumbnail = try await cache.jpeg(for: key) {
try await renderThumbnail()
}
The package combines memory and file-backed storage, typed codecs, single-flight generation for concurrent misses, quota-based trimming, corruption-as-miss behavior, and a UI lifecycle cancellation preset for SwiftUI list and grid workloads.
Yashima is deliberately narrow. It is not a remote image downloader and it is not a database. Nuke and Kingfisher remain the natural choices for remote image pipelines, while SwiftData, Core Data, SQLite, or GRDB are appropriate for data that must be preserved. Yashima is for derived local values that can be deleted and generated again.
The design grew out of production workloads across seven shipped App Store apps, including thumbnails, filter previews, map snapshots, duration metadata, downsampled artwork, and rendered Markdown payloads. The repository includes practical recipes, a sample app, DocC source, a comparison guide, FAQ, and guidance for measuring avoided regeneration in an app.
Requirements are Swift 6.1 or later, iOS 16 or later, and macOS 13 or later. The package is MIT licensed.
Swift Package Index currently reports successful builds with Swift 6.1, 6.2, and 6.3, and hosts the versioned DocC documentation.
GitHub:
Documentation:
https://swiftpackageindex.com/KoichiroKAMADA/Yashima/1.0.0/documentation/yashima
Build results:
https://swiftpackageindex.com/KoichiroKAMADA/Yashima/builds
I would be glad to hear feedback about the API, cache-key design, lifecycle cancellation, or workloads that might fit this kind of cache.