mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2024-11-22 16:23:50 +00:00
commit
8311793a43
@ -1,5 +1,11 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 0.20.34
|
||||||
|
|
||||||
|
* `Repos`:
|
||||||
|
* `Common`:
|
||||||
|
* Improve default `set` realization of `KeyValuesRepo`
|
||||||
|
|
||||||
## 0.20.33
|
## 0.20.33
|
||||||
|
|
||||||
* `Colors`
|
* `Colors`
|
||||||
|
@ -15,5 +15,5 @@ crypto_js_version=4.1.1
|
|||||||
# Project data
|
# Project data
|
||||||
|
|
||||||
group=dev.inmo
|
group=dev.inmo
|
||||||
version=0.20.33
|
version=0.20.34
|
||||||
android_code_version=239
|
android_code_version=240
|
||||||
|
@ -192,6 +192,10 @@ open class FullKeyValuesCacheRepo<Key,Value>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override suspend fun set(toSet: Map<Key, List<Value>>) {
|
||||||
|
super<KeyValuesRepo>.set(toSet)
|
||||||
|
}
|
||||||
|
|
||||||
override suspend fun removeWithValue(v: Value) {
|
override suspend fun removeWithValue(v: Value) {
|
||||||
super<FullWriteKeyValuesCacheRepo>.removeWithValue(v)
|
super<FullWriteKeyValuesCacheRepo>.removeWithValue(v)
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package dev.inmo.micro_utils.repos
|
package dev.inmo.micro_utils.repos
|
||||||
|
|
||||||
|
import dev.inmo.micro_utils.common.diff
|
||||||
import dev.inmo.micro_utils.pagination.*
|
import dev.inmo.micro_utils.pagination.*
|
||||||
import dev.inmo.micro_utils.pagination.utils.doForAllWithNextPaging
|
import dev.inmo.micro_utils.pagination.utils.doForAllWithNextPaging
|
||||||
import dev.inmo.micro_utils.pagination.utils.getAllWithNextPaging
|
import dev.inmo.micro_utils.pagination.utils.getAllWithNextPaging
|
||||||
@ -130,6 +131,14 @@ interface KeyValuesRepo<Key, Value> : ReadKeyValuesRepo<Key, Value>, WriteKeyVal
|
|||||||
|
|
||||||
remove(toRemove)
|
remove(toRemove)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override suspend fun set(toSet: Map<Key, List<Value>>) {
|
||||||
|
toSet.forEach { (k, v) ->
|
||||||
|
val diff = getAll(k).diff(v)
|
||||||
|
remove(k, diff.removed.map { it.value })
|
||||||
|
add(k, diff.added.map { it.value })
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
typealias OneToManyKeyValueRepo<Key,Value> = KeyValuesRepo<Key, Value>
|
typealias OneToManyKeyValueRepo<Key,Value> = KeyValuesRepo<Key, Value>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user