benkuly
10/01/2021, 5:25 PMMutableStateFlow
as a cache for a database (sqldelight). It means, that e. g. I have fun getKeysForUser(userId:String):MutableStateFlow<Keys?>
, which first looks in the cache (just a MutableMap) if it contains a matching MutableStateFlow and if not, creates one with an initial value from the database. It then also launches a coroutine to collect from the MutableStateFlow and write to the database on changes. If there are no subscribers anymore (except from the db-collect), I want to remove it from the cache. What is the best way to do it and does this whole idea work?CLOVIS
10/01/2021, 7:56 PM