# MapWriteKeyValuesRepo

class MapWriteKeyValuesRepo < Key , Value >(map: MutableMap < Key , MutableList < Value >> = mutableMapOf(), locker: SmartRWLocker = SmartRWLocker()) : WriteKeyValuesRepo < Key , Value > (source)

MutableMap-based WriteKeyValuesRepo. All internal operations will be locked with locker (mostly with SmartRWLocker.withWriteLock)

Warning: It is not recommended to use constructor with both MutableMap and SmartRWLocker. Besides, in case you are using your own MutableMap as a map you should be careful with operations on this map

## Constructors

MapWriteKeyValuesRepo
Link copied to clipboard
constructor(map: MutableMap < Key , MutableList < Value >> = mutableMapOf(), locker: SmartRWLocker = SmartRWLocker())

## Properties

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

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

onNewValue
Link copied to clipboard
open override val onNewValue : Flow< Pair < Key , Value >>

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

onValueRemoved
Link copied to clipboard
open override val onValueRemoved : Flow< Pair < Key , Value >>

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

## Functions

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

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: Key )

Fully clears all data associated with the specified key.

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

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 >
remove
Link copied to clipboard
open suspend override fun remove (toRemove: Map < Key , List < Value >>)

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: Value )

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

set
Link copied to clipboard
open suspend override fun set (toSet: Map < Key , List < Value >>)

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.