public interface

FileCache

implements DiskTrimmable
com.facebook.cache.disk.FileCache
Known Indirect Subclasses

Class Overview

Interface that caches based on disk should implement.

Summary

Public Methods
abstract void clearAll()
abstract long clearOldEntries(long cacheExpirationMs)
Deletes old cache files.
abstract long getCount()
abstract DiskStorage.DiskDumpInfo getDumpInfo()
abstract BinaryResource getResource(CacheKey key)
Returns the binary resource cached with key.
abstract long getSize()
abstract boolean hasKey(CacheKey key)
abstract boolean hasKeySync(CacheKey key)
Returns true if the key is in the in-memory key index.
abstract BinaryResource insert(CacheKey key, WriterCallback writer)
Inserts resource into file with key
abstract boolean isEnabled()
Tells if this cache is enabled.
abstract boolean probe(CacheKey key)
abstract void remove(CacheKey key)
Removes a resource by key from cache.
[Expand]
Inherited Methods
From interface com.facebook.common.disk.DiskTrimmable

Public Methods

public abstract void clearAll ()

public abstract long clearOldEntries (long cacheExpirationMs)

Deletes old cache files.

Parameters
cacheExpirationMs files older than this will be deleted.
Returns
  • the age in ms of the oldest file remaining in the cache.

public abstract long getCount ()

Returns
  • the count of pictures in the cache

public abstract DiskStorage.DiskDumpInfo getDumpInfo ()

Throws
IOException

public abstract BinaryResource getResource (CacheKey key)

Returns the binary resource cached with key.

public abstract long getSize ()

Returns
  • the in-use size of the cache

public abstract boolean hasKey (CacheKey key)

public abstract 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.

public abstract BinaryResource insert (CacheKey key, WriterCallback writer)

Inserts resource into file with key

Parameters
key cache key
writer Callback that writes to an output stream
Returns
  • a sequence of bytes
Throws
IOException

public abstract boolean isEnabled ()

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

Returns
  • true if this cache is usable, false otherwise.

public abstract boolean probe (CacheKey key)

public abstract void remove (CacheKey key)

Removes a resource by key from cache.

Parameters
key cache key