#About YNImageAsync is a lightweight and convenient framework for fetching and caching images.
- Fast
- Swift 5 and no ObjC
- Asynchronous image loading with async/await
- LRUCache for both memory and disk cache
- Configurable with size limit for every kind of cache
- Good unit and performance test coverage
- UIImageView extension for fast and out-of-the-box image loading, including built in downsampling optimization.
Follow this guide in order to add YNImageAsync as a dependency to your project.
if let url = URL(string: "https://upload.wikimedia.org/wikipedia/en/5/5f/Original_Doge_meme.jpg") {
imageView.setImage(with: url)
}
imageView.cancelPreviousLoading()
import XCTest
func testCache() async throws {
let memory = MyMemoryCache() // Your implementation of Caching protocol
let disk = MyDiskCache() // Your implementation of Caching protocol
let yourData // Replace with your data
let cacheComposer = CacheComposer(memoryCache: memory, diskCache: disk)
// Save cache to memory and disk
try await cacheComposer.store(url, data)
// Get cached data for key
let data = try await cacheComposer.fetch(url)
XCTAssertEqual(data, yourData)
}
You can easily configure storage during initialization and during runtime as well
await CacheComposer.shared.updateOptions([.memory])
let cache = DiskCacheProvider()
try await cache.updateCacheLimit(UInt64(100 * 1024 * 1024))
- Hash sum checks to update cache
- Swift 5
- iOS 13
YNImageAsync is available under the MIT license. See the LICENSE file for more info.