WriteCRUDCacheRepo

open class WriteCRUDCacheRepo<ObjectType, IdType, InputValueType>(parentRepo: WriteCRUDRepo<ObjectType, IdType, InputValueType>, kvCache: KeyValueRepo<IdType, ObjectType>, scope: CoroutineScope = CoroutineScope(Dispatchers.Default), locker: SmartRWLocker = SmartRWLocker(), idGetter: (ObjectType) -> IdType) : WriteCRUDRepo<ObjectType, IdType, InputValueType> , CommonCacheRepo(source)

Constructors

Link copied to clipboard
constructor(parentRepo: WriteCRUDRepo<ObjectType, IdType, InputValueType>, kvCache: KeyValueRepo<IdType, ObjectType>, scope: CoroutineScope = CoroutineScope(Dispatchers.Default), locker: SmartRWLocker = SmartRWLocker(), idGetter: (ObjectType) -> IdType)

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open override val deletedObjectsIdsFlow: Flow<IdType>

Flow that emits the ID of each deleted object after a successful deleteById call.

Link copied to clipboard
open override val newObjectsFlow: Flow<ObjectType>

Flow that emits each newly created object after a successful create call.

Link copied to clipboard

Mirrors WriteCRUDRepo.deletedObjectsIdsFlow under the name onDeletedObjectsIds for consistency with KV repos naming.

Link copied to clipboard

Mirrors WriteCRUDRepo.newObjectsFlow under the name onNewObjects for consistency with KV repos naming.

Link copied to clipboard

Mirrors WriteCRUDRepo.updatedObjectsFlow under the name onUpdatedObjects for consistency with KV repos naming.

Link copied to clipboard
open override val updatedObjectsFlow: Flow<ObjectType>

Flow that emits each updated object after a successful update call.

Link copied to clipboard

Functions

Link copied to clipboard
fun <ObjectType, IdType, InputType> WriteCRUDRepo<ObjectType, IdType, InputType>.caching(kvCache: KVCache<IdType, ObjectType>, scope: CoroutineScope, locker: SmartRWLocker = SmartRWLocker(), idGetter: (ObjectType) -> IdType): WriteCRUDCacheRepo<ObjectType, IdType, InputType>
Link copied to clipboard
open suspend override fun create(values: List<InputValueType>): List<ObjectType>

Creates new objects from the given list of input values. Successfully created objects must be emitted via newObjectsFlow.

Link copied to clipboard
Link copied to clipboard
open suspend override fun deleteById(ids: List<IdType>)

Deletes objects with the given list of IDs. Successfully deleted IDs must be emitted via deletedObjectsIdsFlow.

Link copied to clipboard

Vararg overload of WriteCRUDRepo.deleteById for convenience.

Link copied to clipboard
open suspend override fun invalidate()

Invalidates its internal data. It may lead to autoreload of data. In case when repo makes autoreload, it must do loading of data before clear

Link copied to clipboard
open suspend override fun update(values: List<UpdatedValuePair<IdType, InputValueType>>): List<ObjectType>

Batch-updates objects using the given list of ID-value pairs. Successfully updated objects must be emitted via updatedObjectsFlow.

open suspend override fun update(id: IdType, value: InputValueType): ObjectType?

Updates the object identified by id with the given value. Successfully updated object must be emitted via updatedObjectsFlow.

Link copied to clipboard
Link copied to clipboard
inline fun <FromKey, FromValue, FromInput, ToKey, ToValue, ToInput> WriteCRUDRepo<ToValue, ToKey, ToInput>.withMapper(noinline keyFromToTo: suspend FromKey.() -> ToKey = { this as ToKey }, noinline valueFromToTo: suspend FromValue.() -> ToValue = { this as ToValue }, noinline inputFromToTo: suspend FromInput.() -> ToInput = { this as ToInput }, noinline keyToToFrom: suspend ToKey.() -> FromKey = { this as FromKey }, noinline valueToToFrom: suspend ToValue.() -> FromValue = { this as FromValue }, noinline inputToToFrom: suspend ToInput.() -> FromInput = { this as FromInput }): WriteCRUDRepo<FromValue, FromKey, FromInput>