AsyncStorage

interface AsyncStorage<K, T, U>

Asynchronous storage contract for persisting and retrieving domain entities.

This interface extends the storage concept with coroutine-based suspend functions for non-blocking I/O operations. All methods are suspendable and should be called within a coroutine context.

This contract was based on roby2014 - uni-projects/TDS

Parameters

K

The type used to identify entities (e.g., String for names, Int for IDs).

T

The domain entity type being stored.

U

The storage format type used internally by the serializer (e.g., String, ByteArray).

Inheritors

Properties

Link copied to clipboard
abstract val serializer: Serializer<T, U>

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

Functions

Link copied to clipboard
abstract suspend fun close()

Closes the storage, releasing any held resources.

Link copied to clipboard
abstract suspend fun delete(id: K)

Deletes an entity from storage by its identifier.

Link copied to clipboard
abstract suspend fun lastModified(id: K): Long?

Gets the last modification timestamp for an entity.

Link copied to clipboard
abstract suspend fun load(id: K): T?

Retrieves an entity from storage by its identifier.

Link copied to clipboard
abstract suspend fun loadAllIds(): List<K>

Loads all identifiers currently stored in this storage.

Link copied to clipboard
abstract suspend fun new(id: K, factory: () -> T): T

Creates a new entity in storage with the given identifier.

Link copied to clipboard
abstract suspend fun save(id: K, obj: T)

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