public final class OkioStorage<T extends Object> implements Storage


OKIO implementation of the Storage interface, providing cross platform IO using the OKIO library.

Summary

Public constructors

<T extends Object> OkioStorage(
    @NonNull FileSystem fileSystem,
    @NonNull OkioSerializer<@NonNull T> serializer,
    @NonNull Function2<@NonNull Path, @NonNull FileSystem, @NonNull InterProcessCoordinator> coordinatorProducer,
    @NonNull Function0<@NonNull Path> producePath
)

Public methods

@NonNull StorageConnection<@NonNull T>

Creates a storage connection which allows reading and writing to the underlying storage.

Public constructors

OkioStorage

public <T extends Object> OkioStorage(
    @NonNull FileSystem fileSystem,
    @NonNull OkioSerializer<@NonNull T> serializer,
    @NonNull Function2<@NonNull Path, @NonNull FileSystem, @NonNull InterProcessCoordinator> coordinatorProducer,
    @NonNull Function0<@NonNull Path> producePath
)
Parameters
@NonNull FileSystem fileSystem

The file system to perform IO operations on.

@NonNull OkioSerializer<@NonNull T> serializer

The serializer for T.

@NonNull Function2<@NonNull Path, @NonNull FileSystem, @NonNull InterProcessCoordinator> coordinatorProducer

The producer to provide InterProcessCoordinator that coordinates IO operations across processes if needed. By default it provides single process coordinator, which doesn't support cross process use cases.

@NonNull Function0<@NonNull Path> producePath

The file producer that returns the file path that will be read and written.

Public methods

createConnection

Added in 1.1.1
public @NonNull StorageConnection<@NonNull T> createConnection()

Creates a storage connection which allows reading and writing to the underlying storage.

Should be closed after usage.

Throws
okio.IOException

Unrecoverable IO exception when trying to access the underlying storage.