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

Allow ImageCache/ImageRequestCache methods to be async #480

Open
1 task done
bbrk24 opened this issue Sep 9, 2024 · 0 comments
Open
1 task done

Allow ImageCache/ImageRequestCache methods to be async #480

bbrk24 opened this issue Sep 9, 2024 · 0 comments

Comments

@bbrk24
Copy link

bbrk24 commented Sep 9, 2024

What did you do?

I'm currently trying to implement an ImageRequestCache that uses persistent (on-disk) storage for images so that the cache lives between sessions. This is faster than making a network request, but should still be done asynchronously. Currently, I have to use awkward workarounds to fulfill image(withIdentifier:), and the return values for the various overloads of removeImage aren't necessarily accurate.

What did you expect to happen?

Since functions that use the image cache are asynchronous anyways (they may need to make a network request to get the image), there's no reason the cache itself can't be asynchronous. This would also allow AutoPurgingImageCache to use an actor to protect its storage rather than synchronously dispatching to a Dispatch queue.

What happened instead?

Image cache methods must be synchronous.

Alamofire Environment

Alamofire version: 5.6.3
Xcode version: 15.2
Swift version: 5.10
Platform(s) running AlamofireImage: iOS 14.5 and later
macOS version running Xcode: 14.6.1

Demo Project

The repo I'm implementing this for is private, but I can see if I can get permission to make the ImageRequestCache implementation public for this issue, if need be.

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

No branches or pull requests

1 participant