Package 

Class DiskStorageCache

  • All Implemented Interfaces:
    com.facebook.cache.disk.FileCache , com.facebook.common.disk.DiskTrimmable

    @ThreadSafe() 
    public class DiskStorageCache
     implements FileCache, DiskTrimmable
                        

    Cache that manages disk storage.

    • Method Detail

      • isEnabled

         boolean isEnabled()

        Tells if this cache is enabled. It's important for some caches that can be disabled withoutfurther notice (like in removable/unmountable storage). Anyway a disabled cache should justignore calls, not fail.

      • isIndexReady

         boolean isIndexReady()

        Tells if memory index is completed in initialization. Only call it when you need to know ifmemory index is completed in cold start.

      • getResource

        @Nullable() BinaryResource getResource(CacheKey key)

        Retrieves the file corresponding to the mKey, if it is in the cache. Also touches the item,thus changing its LRU timestamp. If the file is not present in the file cache, returns null.

        This should NOT be called on the UI thread.

        Parameters:
        key - the mKey to check
      • probe

         boolean probe(CacheKey key)

        Probes whether the object corresponding to the mKey is in the cache. Note that the act ofprobing touches the item (if present in cache), thus changing its LRU timestamp.

        This will be faster than retrieving the object, but it still has file system accesses andshould NOT be called on the UI thread.

        Parameters:
        key - the mKey to check
      • remove

         void remove(CacheKey key)

        Removes a resource by key from cache.

        Parameters:
        key - cache key
      • clearOldEntries

         long clearOldEntries(long cacheExpirationMs)

        Deletes old cache files.

        Parameters:
        cacheExpirationMs - files older than this will be deleted.
      • hasKeySync

         boolean hasKeySync(CacheKey key)

        Returns true if the key is in the in-memory key index.

        Not guaranteed to be correct. The cache may yet have this key even if this returns false.But if it returns true, it definitely has it.

        Avoids a disk read.