-
Notifications
You must be signed in to change notification settings - Fork 334
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ImageWrapper overhead #174
Comments
@gabors Hi this is a valid concern. I will check it |
Appreciate it. |
@gabors I was using |
Yeah I appreciate that. This would not work with the current ImageWrapper per se but if we receive a Data (which is an image) from a URL we could cache that directly.
|
Hi, please take a look if you want at https://github.com/gabors/Cache/commit/4ece09fae2bb6dc278e9592c9e1c1d9ccce3e775 in my quick test with 110 thumbnail images, the ImageWrapper based cache took up 65MB and when saving the Data directly and bypassing serialization (for Data) the cache takes up 12MB. |
How about storing the images in the file system and just save the directory path (as a In the previous version of my app, I was using the same mechanism but I was using |
Storing the image data in the file system separately is an option but then you need to take care of expired files cleanup yourself, which sounds like a lot of work, and that's what this library is supposed to help with. |
@gabors agree, but remember that the idea behind |
@annjawn My use case if caching hundreds of smallish thumbnail images that are accessed VERY frequently by the app so i cache them for several hours. |
Well in that case you need to look at the SDWebImage library. It has a pretty strong inbuilt caching system for images, compression, decompression options and much more. Very easy to use and well thought out library. I use both SDWebImage and Cache in my app which is live in AppStore and they both, although used for different purposes, work very well. |
@annjawn Thanks I'll check it out again. Last time I looked it had a lot of functionality I did not need, as I have my own compression/decompression options. |
@gabors You can now take a look at https://github.com/hyperoslo/Cache/releases/tag/5.0.0 |
Thanks for the excellent cache library.
When using for caching images I noticed that you take the UIImage data as PNG or JPEG then serialize it into a JSON like
{"object":{"image":"\/9j\/4AAQSkZJRgABAQAASABIAAD\/4QBYRXhpZ...
This transformation I'm afraid is expensive, the resulting cache files also are easily double in size from the original binary. Then when we retrieve the data from the cache we have to deserialize it again.
So what happens now:
3.1 Convert back to Data as PNG or JSON, depending on Alpha channel, again
3.2 Wrap it into a Codable
3.3 Serialize into JSON text (larger size)
3.4 Save to cache (disk and memory)
then in reverse when retrieving..
I prefer the way your previous Swift 3 version of the library worked where it would cache the actual data we fetch from a URL.
The text was updated successfully, but these errors were encountered: