public interface

DiskStorage

com.facebook.cache.disk.DiskStorage
Known Indirect Subclasses

Class Overview

Storage for files in the cache. Responsible for maintaining state (count, size, watch file existence, reachability)

Summary

Nested Classes
class DiskStorage.DiskDumpInfo  
class DiskStorage.DiskDumpInfoEntry  
interface DiskStorage.Entry  
interface DiskStorage.Inserter This is a builder-like interface returned when calling insert. 
Public Methods
abstract void clearAll()
Clear all contents of the storage
abstract boolean contains(String resourceId, Object debugInfo)
Does a resource with this name exist?
abstract DiskStorage.DiskDumpInfo getDumpInfo()
abstract Collection<DiskStorage.Entry> getEntries()
Get all entries currently in the storage
abstract BinaryResource getResource(String resourceId, Object debugInfo)
Get the resource with the specified name
abstract String getStorageName()
Get the storage's name, which should be unique
abstract DiskStorage.Inserter insert(String resourceId, Object debugInfo)
Creates a temporary resource for writing content.
abstract boolean isEnabled()
is this storage enabled?
abstract boolean isExternal()
is this storage external?
abstract void purgeUnexpectedResources()
abstract long remove(DiskStorage.Entry entry)
Remove the resource represented by the entry
abstract long remove(String resourceId)
Remove the resource with specified id
abstract boolean touch(String resourceId, Object debugInfo)
Does a resource with this name exist? If so, update the last-accessed time for the resource

Public Methods

public abstract void clearAll ()

Clear all contents of the storage

Throws
IOException
IOException

public abstract boolean contains (String resourceId, Object debugInfo)

Does a resource with this name exist?

Parameters
resourceId id of the resource
debugInfo helper object for debugging
Returns
  • true, if the resource is present in the storage, false otherwise
Throws
IOException

public abstract DiskStorage.DiskDumpInfo getDumpInfo ()

Throws
IOException

public abstract Collection<DiskStorage.Entry> getEntries ()

Get all entries currently in the storage

Returns
  • a collection of entries in storage
Throws
IOException

public abstract BinaryResource getResource (String resourceId, Object debugInfo)

Get the resource with the specified name

Parameters
resourceId id of the resource
debugInfo helper object for debugging
Returns
  • the resource with the specified name. NULL if not found
Throws
IOException for unexpected behavior.

public abstract String getStorageName ()

Get the storage's name, which should be unique

Returns
  • name of the this storage

public abstract DiskStorage.Inserter insert (String resourceId, Object debugInfo)

Creates a temporary resource for writing content. Split from commit() in order to allow concurrent writing of cache entries. This entry will not be available to cache clients until commit() is called passing in the resource returned from this method.

Parameters
resourceId id of the resource
debugInfo helper object for debugging
Returns
  • the Inserter object with methods to write data, commit or cancel the insertion
Throws
IOException on errors during this operation

public abstract boolean isEnabled ()

is this storage enabled?

Returns
  • true, if enabled

public abstract boolean isExternal ()

is this storage external?

Returns
  • true, if external

public abstract void purgeUnexpectedResources ()

public abstract long remove (DiskStorage.Entry entry)

Remove the resource represented by the entry

Parameters
entry entry of the resource to delete
Returns
  • size of deleted file if successfully deleted, -1 otherwise
Throws
IOException

public abstract long remove (String resourceId)

Remove the resource with specified id

Returns
  • size of deleted file if successfully deleted, -1 otherwise
Throws
IOException

public abstract boolean touch (String resourceId, Object debugInfo)

Does a resource with this name exist? If so, update the last-accessed time for the resource

Parameters
resourceId id of the resource
debugInfo helper object for debugging
Returns
  • true, if the resource is present in the storage, false otherwise
Throws
IOException