LocalDataSource

interface LocalDataSource<E : Any>

The local persistence side of a Repository. Mirrors SwiftyNetwork's LocalDataSource.

Type Parameters

E

the stored entity type.

Inheritors

Functions

Link copied to clipboard
open fun changes(): Flow<CacheChange>

A hot stream of CacheChanges for the underlying store, enabling reactive reads via Repository.stream. The default is an empty flow (non-reactive source).

Link copied to clipboard
open suspend fun entry(key: CacheKey): CacheEntry<E>?

Atomically returns the entity and its timestamp for key, or null if absent.

Link copied to clipboard
abstract suspend fun read(key: CacheKey): E?

Returns the entity stored for key, or null.

Link copied to clipboard
abstract suspend fun remove(key: CacheKey)

Removes the entity stored for key.

Link copied to clipboard
abstract suspend fun removeAll()

Removes all stored entities.

Link copied to clipboard
abstract suspend fun timestamp(key: CacheKey): Long?

Returns the epoch-millisecond timestamp recorded for key, or null.

Link copied to clipboard
abstract suspend fun write(entity: E, key: CacheKey)

Stores entity for key.