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.
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 fulfillimage(withIdentifier:)
, and the return values for the various overloads ofremoveImage
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.