question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Expose Cached Files

See original GitHub issue

It would be nice to have the ability to see if the image has already been cached to disk and/or memory. A simple call like

Fresco.existsInDiskCache(Uri uri) and Fresco.existsInMemoryCache(Uri uri)

Maybe a separate request but related is the ability to retrieve the cached resource from disk. The use case being that after we have retrieved the image the app may have a feature that allows the user to share the image. If we could access the local uri of the cached image then we can pass it to share intent.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:15 (6 by maintainers)

github_iconTop GitHub Comments

3reactions
krmaocommented, Sep 11, 2015
 public static boolean isImageDownloaded(Uri loadUri) {
        if (loadUri == null) {
            return false;
        }
        CacheKey cacheKey = DefaultCacheKeyFactory.getInstance().getEncodedCacheKey(ImageRequest.fromUri(loadUri));
        return ImagePipelineFactory.getInstance().getMainDiskStorageCache().hasKey(cacheKey) || ImagePipelineFactory.getInstance().getSmallImageDiskStorageCache().hasKey(cacheKey);
    }

    //return file or null
    public static File getCachedImageOnDisk(Uri loadUri) {
        File localFile = null;
        if (loadUri != null) {
            CacheKey cacheKey = DefaultCacheKeyFactory.getInstance().getEncodedCacheKey(ImageRequest.fromUri(loadUri));
            if (ImagePipelineFactory.getInstance().getMainDiskStorageCache().hasKey(cacheKey)) {
                BinaryResource resource = ImagePipelineFactory.getInstance().getMainDiskStorageCache().getResource(cacheKey);
                localFile = ((FileBinaryResource) resource).getFile();
            } else if (ImagePipelineFactory.getInstance().getSmallImageDiskStorageCache().hasKey(cacheKey)) {
                BinaryResource resource = ImagePipelineFactory.getInstance().getSmallImageDiskStorageCache().getResource(cacheKey);
                localFile = ((FileBinaryResource) resource).getFile();
            }
        }
        return localFile;
    }

@danhantao

0reactions
tyronencommented, May 23, 2016
Read more comments on GitHub >

github_iconTop Results From Across the Web

How To See Cached Pages And Files From Your Browser
On Windows, the path to locate the browser cache is a little different. For example, for Google Chrome it looks like this: C:\Users\USERNAME\ ......
Read more >
How to Recover Cache Files in Google Chrome
1. Click the address bar at the top of your Google Chrome window, type “About:cache” into the box and press “Enter.” A page...
Read more >
What is caching and how does it work? - Wired UK
If you've ever deleted your browsing history, it's likely you've come across the phrase “clearing your cache” (pronounced 'cash').
Read more >
Amazon File Cache – A High Performance Cache On AWS ...
File Cache creates a file system–based cache in front of either NFS v3 file systems or S3 buckets in one or more Regions....
Read more >
amazon web services - AWS S3 - Cached files - Stack Overflow
2 Answers 2 · So I understand that caching is a very good thing. My problem is that I'm exposing an article catalog...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found