# AutoRecacheWriteKeyValuesRepo

open class AutoRecacheWriteKeyValuesRepo < Id , RegisteredObject >(originalRepo: WriteKeyValuesRepo < Id , RegisteredObject >, scope: CoroutineScope, kvCache: KeyValueRepo < Id , List < RegisteredObject >> = MapKeyValueRepo()) : WriteKeyValuesRepo < Id , RegisteredObject > , FallbackCacheRepo (source)

## Constructors

AutoRecacheWriteKeyValuesRepo
Link copied to clipboard
constructor(originalRepo: WriteKeyValuesRepo < Id , RegisteredObject >, scope: CoroutineScope, kvCache: KeyValueRepo < Id , List < RegisteredObject >> = MapKeyValueRepo())

## Properties

onDataCleared
Link copied to clipboard
open override val onDataCleared : Flow< Id >

Flow that emits when all data for a key is cleared.

onNewValue
Link copied to clipboard
open override val onNewValue : Flow< Pair < Id , RegisteredObject >>

Flow that emits when a new value is added to a key.

onValueRemoved
Link copied to clipboard
open override val onValueRemoved : Flow< Pair < Id , RegisteredObject >>

Flow that emits when a value is removed from a key.

## Functions

add
Link copied to clipboard
open suspend override fun add (toAdd: Map < Id , List < RegisteredObject >>)

Adds values to the specified keys.

add
Link copied to clipboard
inline suspend fun < Key , Value > WriteKeyValuesRepo < Key , Value >. add (k: Key , v: List < Value >)

Single-key overload of WriteKeyValuesRepo.add accepting a list of values.

inline suspend fun < Key , Value > WriteKeyValuesRepo < Key , Value >. add (k: Key , vararg v: Value )

Single-key vararg overload of WriteKeyValuesRepo.add.

caching
Link copied to clipboard
fun < Key , Value > WriteKeyValuesRepo < Key , Value >. caching (kvCache: KeyValueRepo < Key , List < Value >>, scope: CoroutineScope = CoroutineScope(Dispatchers.Default), locker: SmartRWLocker = SmartRWLocker()): FullWriteKeyValuesCacheRepo < Key , Value >
clear
Link copied to clipboard
open suspend override fun clear (k: Id )

Fully clears all data associated with the specified key.

clearWithValue
Link copied to clipboard
open suspend override fun clearWithValue (v: RegisteredObject )

Clears a specific value from all keys and removes those keys if they become empty.

directlyCached
Link copied to clipboard
fun < Key , Value > WriteKeyValuesRepo < Key , Value >. directlyCached (kvCache: KeyValueRepo < Key , List < Value >>, scope: CoroutineScope = CoroutineScope(Dispatchers.Default), locker: SmartRWLocker = SmartRWLocker()): DirectFullWriteKeyValuesCacheRepo < Key , Value >
invalidate
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

remove
Link copied to clipboard
open suspend override fun remove (toRemove: Map < Id , List < RegisteredObject >>)

Removes specific values from keys without clearing all data for those keys.

remove
Link copied to clipboard
inline suspend fun < Key , Value > WriteKeyValuesRepo < Key , Value >. remove (keysAndValues: List < Pair < Key , List < Value >>>)

List-of-pairs overload of WriteKeyValuesRepo.remove.

inline suspend fun < Key , Value > WriteKeyValuesRepo < Key , Value >. remove (vararg keysAndValues: Pair < Key , List < Value >>)

Vararg overload of WriteKeyValuesRepo.remove.

inline suspend fun < Key , Value > WriteKeyValuesRepo < Key , Value >. remove (k: Key , v: List < Value >)

Single-key overload of WriteKeyValuesRepo.remove accepting a list of values.

inline suspend fun < Key , Value > WriteKeyValuesRepo < Key , Value >. remove (k: Key , vararg v: Value )

Single-key vararg overload of WriteKeyValuesRepo.remove.

removeWithValue
Link copied to clipboard
open suspend override fun removeWithValue (v: RegisteredObject )

Removes a specific value from all keys that contain it, without clearing all data for those keys.

set
Link copied to clipboard
open suspend fun set (toSet: Map < Id , List < RegisteredObject >>)

Sets the values for specified keys, clearing any existing values first.

set
Link copied to clipboard
inline suspend fun < Key , Value > WriteKeyValuesRepo < Key , Value >. set (k: Key , v: List < Value >)

Single-key overload of WriteKeyValuesRepo.set accepting a list of values.

inline suspend fun < Key , Value > WriteKeyValuesRepo < Key , Value >. set (k: Key , vararg v: Value )

Single-key vararg overload of WriteKeyValuesRepo.set.

withMapper
Link copied to clipboard
inline fun < FromKey , FromValue , ToKey , ToValue > WriteKeyValuesRepo < ToKey , ToValue >. withMapper (mapper: MapperRepo < FromKey , FromValue , ToKey , ToValue >): WriteKeyValuesRepo < FromKey , FromValue >

Wraps this WriteKeyValuesRepo with a MapperRepo to expose a mapped WriteKeyValuesRepo.

inline fun < FromKey , FromValue , ToKey , ToValue > WriteKeyValuesRepo < ToKey , ToValue >. withMapper (noinline keyFromToTo: suspend FromKey .() -> ToKey = { this as ToKey }, noinline valueFromToTo: suspend FromValue .() -> ToValue = { this as ToValue }, noinline keyToToFrom: suspend ToKey .() -> FromKey = { this as FromKey }, noinline valueToToFrom: suspend ToValue .() -> FromValue = { this as FromValue }): WriteKeyValuesRepo < FromKey , FromValue >

Wraps this WriteKeyValuesRepo with inline conversion lambdas to expose a mapped WriteKeyValuesRepo.