Skip to content

ImageWrapper overhead  #174

Closed
Closed
@gabors

Description

@gabors

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:

  1. Fetch data from URL
  2. Load it into UIImage
  3. Send it to Cache:
    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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions