-
- All Implemented Interfaces:
-
com.facebook.common.disk.DiskTrimmable
public interface FileCache implements DiskTrimmableInterface that caches based on disk should implement.
-
-
Method Summary
Modifier and Type Method Description abstract booleanisEnabled()Tells if this cache is enabled. abstract BinaryResourcegetResource(CacheKey key)Returns the binary resource cached with key. abstract booleanhasKeySync(CacheKey key)Returns true if the key is in the in-memory key index. abstract booleanhasKey(CacheKey key)abstract booleanprobe(CacheKey key)abstract BinaryResourceinsert(CacheKey key, WriterCallback writer)Inserts resource into file with key abstract voidremove(CacheKey key)Removes a resource by key from cache. abstract longgetSize()abstract longgetCount()abstract longclearOldEntries(long cacheExpirationMs)Deletes old cache files. abstract voidclearAll()abstract DiskStorage.DiskDumpInfogetDumpInfo()-
-
Method Detail
-
isEnabled
abstract 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.
-
getResource
@Nullable() abstract BinaryResource getResource(CacheKey key)
Returns the binary resource cached with key.
-
hasKeySync
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.
-
insert
@Nullable() abstract BinaryResource insert(CacheKey key, WriterCallback writer)
Inserts resource into file with key
- Parameters:
key- cache keywriter- Callback that writes to an output stream
-
remove
abstract void remove(CacheKey key)
Removes a resource by key from cache.
- Parameters:
key- cache key
-
getSize
abstract long getSize()
-
getCount
abstract long getCount()
-
clearOldEntries
abstract long clearOldEntries(long cacheExpirationMs)
Deletes old cache files.
- Parameters:
cacheExpirationMs- files older than this will be deleted.
-
clearAll
abstract void clearAll()
-
getDumpInfo
abstract DiskStorage.DiskDumpInfo getDumpInfo()
-
-
-
-