Skip to content
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

Expose protocol to get image data from the cache plus WebP cleanup #644

Merged

Conversation

andyfinnell
Copy link
Contributor

Summary

Recently we made several headers private in Cocoapods. However, some clients were reaching directly into PINRemoteImage's memory cache (PINCache) and pulling out PINRemoteImageMemoryContainer and doing whatever with it. To support that use case without exposing more than necessary publicly, introduce the PINRemoteImageDataConvertible protocol and have PINRemoteImageMemoryContainer conform to it.

So if previously the code was:

PINRemoteImageMemoryContainer *container = [[PINRemoteImageManager sharedImageManager].cache objectFromMemoryForKey:imageURL.absoluteString];
NSData *cachedImageDataForURL = [container data];

it can be

id<PINRemoteImageDataConvertible> container = [[PINRemoteImageManager sharedImageManager].cache objectFromMemoryForKey:imageURL.absoluteString];
NSData *cachedImageDataForURL = [container data];

Also, previous changes required PIN_WEBP to be defined in the project settings or it would fail to compile. That's been changed to always build. If not specified it will default to 1.

Test plan

Run make all to run tests and build everything

## Summary

Recently we made several headers private in Cocoapods. However, some clients were reaching directly into PINRemoteImage's memory cache (PINCache) and pulling out `PINRemoteImageMemoryContainer` and doing whatever with it. To support that use case without exposing more than necessary publicly, introduce the `PINRemoteImageDataConvertible` protocol and have `PINRemoteImageMemoryContainer` conform to it.

So if previously the code was:

```
PINRemoteImageMemoryContainer *container = [[PINRemoteImageManager sharedImageManager].cache objectFromMemoryForKey:imageURL.absoluteString];
NSData *cachedImageDataForURL = [container data];
```
it can be
```
id<PINRemoteImageDataConvertible> container = [[PINRemoteImageManager sharedImageManager].cache objectFromMemoryForKey:imageURL.absoluteString];
NSData *cachedImageDataForURL = [container data];
```

Also, previous changes required `PIN_WEBP` to be defined in the project settings or it would fail to compile. That's been changed to always build. If _not_ specified it will default to `1`.

## Test plan

Run `make all` to run tests and build everything
@andyfinnell andyfinnell requested review from rcancro and rgnns May 23, 2024 19:35
@andyfinnell andyfinnell merged commit 26818dc into pinterest:master May 23, 2024
6 checks passed
@andyfinnell andyfinnell deleted the expose-protocol-for-cache-image-data branch May 23, 2024 20:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants