ConvCache
Features
- Asynchronous image downloading and caching.
- Loading image from either URLSession-based networking or local provided data.
- Multiple-layer hybrid cache for both memory and disk.
- Fine control on cache behavior. Customizable expiration date and size limit.
- Leverage ETags to support cache modernization
- Prefetching images and showing them from the cache to boost your app.
Example
To run the example project, clone the repo, and run pod install
from the Example directory first.
Requirements
iOS | Xcode |
---|---|
13+ | 13 |
Installation
Cocoapods
pod 'ConvCache'
Usage
You can use it by entering the image URL you want to import in the example URL.
ConvCache.default.setData(URLStr: "https://example.com") { [weak self] result in
switch result {
case let .success(data):
DispatchQueue.main.async {
self?.imageView.image = UIImage(data: data)
}
case let .failure(error):
print(error.localizedDescription)
}
}
The default capacity is set to 100 MB for memory and 50 MB for disk. If you want to change the capacity, you can set it as shown in the example below (as an integer)
ConvCache.default.configureCache(with: memoryBytes, with: diskBytes)
Author
oguuk, ogw135@gmail.com
License
ConvCache is available under the MIT license. See the LICENSE file for more info.