CacheDataSink.Factory


public final class CacheDataSink.Factory implements DataSink.Factory


DataSink.Factory for CacheDataSink instances.

Summary

Public constructors

Creates an instance.

Public methods

DataSink

Creates a DataSink instance.

CacheDataSink.Factory

Sets the size of an in-memory buffer used when writing to a cache file.

CacheDataSink.Factory

Sets the cache to which data will be written.

CacheDataSink.Factory

Sets the cache file fragment size.

Public constructors

Factory

public Factory()

Creates an instance.

Public methods

createDataSink

public DataSink createDataSink()

Creates a DataSink instance.

setBufferSize

@CanIgnoreReturnValue
public CacheDataSink.Factory setBufferSize(int bufferSize)

Sets the size of an in-memory buffer used when writing to a cache file. A zero or negative value disables buffering.

The default value is DEFAULT_BUFFER_SIZE.

Parameters
int bufferSize

The buffer size in bytes.

Returns
CacheDataSink.Factory

This factory.

setCache

@CanIgnoreReturnValue
public CacheDataSink.Factory setCache(Cache cache)

Sets the cache to which data will be written.

Must be called before the factory is used.

Parameters
Cache cache

The cache to which data will be written.

Returns
CacheDataSink.Factory

This factory.

setFragmentSize

@CanIgnoreReturnValue
public CacheDataSink.Factory setFragmentSize(long fragmentSize)

Sets the cache file fragment size. For requests that should be fragmented into multiple cache files, this is the maximum size of a cache file in bytes. If set to LENGTH_UNSET then no fragmentation will occur. Using a small value allows for finer-grained cache eviction policies, at the cost of increased overhead both on the cache implementation and the file system. Values under (2 * 1024 * 1024) are not recommended.

The default value is DEFAULT_FRAGMENT_SIZE.

Parameters
long fragmentSize

The fragment size in bytes, or LENGTH_UNSET to disable fragmentation.

Returns
CacheDataSink.Factory

This factory.