SDWebImageLinkPlugin
SDWebImageLinkPlugin copied to clipboard
Check for cached LPLinkMeta?
Is there a way to check if cached LPLinkMetadata exists for a URL? And then, if the LPLinkMetadata does NOT exist in the cache, saving custom LPLinkMetadata to the cache by providing a url, title, and image url?
I would like to do this without actually showing any images; i.e. without using UIImageView or LPLinkView. This would be purely backend.
If you don't need any UIImageView/LPLinkView. You can just use SDImageCache to query the cache existence. Just as normal HTTP URL.
After query, you can decode the LPLinkMetadata from the sd_extendedObject of the UIImage, check that object's class and grab back.
If you just want to know whether this is cached or not, just check for that cache key (SDImageCache has API: imageDataExist), don't need to query the image and LPLinkMetadata back.
See: https://github.com/SDWebImage/SDWebImageLinkPlugin/blob/master/SDWebImageLinkPlugin/Classes/LPLinkView%2BWebCache.m#L94
How can I query the SDImageCache for cached LPLinkMetaData? I see no methods for that.
How can I cache LPLinkMetaData without instantiating an image?
On Aug 9, 2020, at 3:33 AM, DreamPiggy [email protected] wrote:
If you don't need any UIImageView/LPLinkView. You can just use SDImageCache to query the cache existence.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.
The LPLinkMetadata is encoded use keyed-archive and stored into Image Data’s xattr (See: https://en.m.wikipedia.org/wiki/Extended_file_attributes)
You can get the Image Data path by using SDImageCache.cachePathForKey
Then using POSIX API to grab xattr. We have a non-public helper API here, used internally: https://github.com/SDWebImage/SDWebImage/blob/5.8.3/SDWebImage/Private/SDFileAttributeHelper.h
Then using keyed-unarchive to decode into LPLinkMetadata class.