DatabaseManager

Manages per-device Room database instances for node data, with LRU eviction.

Constructors

Link copied to clipboard
constructor(app: Application, dispatchers: CoroutineDispatchers)

Properties

Link copied to clipboard
open override val cacheLimit: StateFlow<Int>
Link copied to clipboard
val currentAddress: StateFlow<String?>
Link copied to clipboard
open override val currentDb: StateFlow<MeshtasticDatabase>

Reactive stream of the currently active database instance.

Link copied to clipboard

Functions

Link copied to clipboard
fun close()

Closes all open databases and cancels background work.

Link copied to clipboard
open override fun getCurrentCacheLimit(): Int
Link copied to clipboard
open override fun hasDatabaseFor(address: String?): Boolean

Returns true if a database exists for the given device address.

Link copied to clipboard
suspend fun init(address: String?)

Initialize the active database for address.

Link copied to clipboard
open override fun setCacheLimit(limit: Int)
Link copied to clipboard
open suspend override fun switchActiveDatabase(address: String?)

Switch active database to the one associated with address. Serialized via mutex.

Link copied to clipboard
open suspend override fun <T> withDb(block: suspend (MeshtasticDatabase) -> T): T?

Execute block with the current DB instance.