public static interface

DiskStorage.Inserter

com.facebook.cache.disk.DiskStorage.Inserter

Class Overview

This is a builder-like interface returned when calling insert. It holds all the operations carried through an insert(String, Object) operation: - writing data - committing - clean up

Summary

Public Methods
abstract boolean cleanUp()
Discards the insertion process.
abstract BinaryResource commit(Object debugInfo)
Commits the insertion into the cache.
abstract BinaryResource commit(Object debugInfo, long time)
Commits the insertion into the cache.
abstract void writeData(WriterCallback callback, Object debugInfo)
Update the contents of the resource to be inserted.

Public Methods

public abstract boolean cleanUp ()

Discards the insertion process. If resource was already committed the call is ignored.

Returns
  • true if cleanUp is successful (or noop), false if something couldn't be dealt with

public abstract BinaryResource commit (Object debugInfo)

Commits the insertion into the cache. Once this is called the entry will be available to clients of the cache.

Parameters
debugInfo debug object for debugging
Returns
  • the final resource created
Throws
IOException on errors during the commit

public abstract BinaryResource commit (Object debugInfo, long time)

Commits the insertion into the cache. Once this is called the entry will be available to clients of the cache. It also sets the file's timestamp according to the time passed as an argument.

Parameters
debugInfo debug object for debugging
time in milliseconds
Returns
  • the final resource created
Throws
IOException on errors during the commit

public abstract void writeData (WriterCallback callback, Object debugInfo)

Update the contents of the resource to be inserted. Executes outside the session lock. The writer callback will be provided with an OutputStream to write to. For high efficiency client should make sure that data is written in big chunks (for example by employing BufferedInputStream or writing all data at once).

Parameters
callback the write callback
debugInfo helper object for debugging
Throws
IOException