public final class CacheWriter extends ObjectCaching related utility methods.
Nested Class Summary
Nested Classes Modifier and Type Class Description
CacheWriter.ProgressListenerReceives progress updates during cache operations.
Fields Modifier and Type Field Description
DEFAULT_BUFFER_SIZE_BYTESDefault buffer size to be used while caching.
All Methods Instance Methods Concrete Methods Modifier and Type Method Description
cache()Caches the requested data, skipping any that's already cached.
cancel()Cancels this writer's caching operation.
public static final int DEFAULT_BUFFER_SIZE_BYTESDefault buffer size to be used while caching.
- See Also:
- Constant Field Values
public CacheWriter(CacheDataSource dataSource, DataSpec dataSpec, @Nullable byte temporaryBuffer, @Nullable CacheWriter.ProgressListener progressListener)
CacheDataSourcethat writes to the target cache.
dataSpec- Defines the data to be written.
temporaryBuffer- A temporary buffer to be used during caching, or
nullif the writer should instantiate its own internal temporary buffer.
progressListener- An optional progress listener.
public void cancel()
@WorkerThread public void cache() throws IOExceptionCaches the requested data, skipping any that's already cached.
CacheDataSourceused by the writer has a
PriorityTaskManager, then it's the responsibility of the caller to call
PriorityTaskManager.add(int)to register with the manager before calling this method, and to call
PriorityTaskManager.remove(int)afterwards to unregister.
PriorityTaskManager.PriorityTooLowExceptionwill be thrown if the priority required by the
CacheDataSourceis not high enough for progress to be made.
This method may be slow and shouldn't normally be called on the main thread.