AsyncFileStorage

data class AsyncFileStorage<T>(val folder: String, val serializer: Serializer<T, String>) : AsyncStorage<String, T, String>

AsyncStorage implementation via file + text strings.

This method was based from roby2014 - uni-projects/TDS

Parameters

T

Type of the domain entity

folder

Folder where the file will be stored

Constructors

Link copied to clipboard
constructor(folder: String, serializer: Serializer<T, String>)

Properties

Link copied to clipboard
private val fileStorage: FileStorage<T>
Link copied to clipboard
private val folder: String
Link copied to clipboard
open override val serializer: Serializer<T, String>

The serializer responsible for converting entities to/from the storage format.

Functions

Link copied to clipboard
open suspend override fun close()

Closes the async file storage, releasing any held resources.

Link copied to clipboard
open suspend override fun delete(id: String)

Deletes an entity from async file storage by its identifier.

Link copied to clipboard
open suspend override fun lastModified(id: String): Long?

Gets the last modification timestamp for an entity in async file storage.

Link copied to clipboard
open suspend override fun load(id: String): T?

Retrieves an entity from async file storage by its identifier.

Link copied to clipboard
open suspend override fun loadAllIds(): List<String>

Loads all entity identifiers currently stored in this async file storage.

Link copied to clipboard
open suspend override fun new(id: String, factory: () -> T): T

Creates a new entity in async file storage with the given identifier.

Link copied to clipboard
open suspend override fun save(id: String, obj: T)

Saves (persists) an entity in async file storage under the given identifier.