Sunday, 23 April 2023

Does Room automatically cache calls to compileStatement?

I am using Room and I like to write my own queries. I am wondering if Room automatically cache calls to compileStatement, or do I need to cache them myselfs? This is an example of my query:

fun updateAllowMessagesByInRangeRegularUsersAllRows(database: GeneratedDatabase, allowMessagesByInRangeRegularUsers: Boolean) {
    // Will this be recomputed all the time?
    val stmt = database.compileStatement("update Conversation set allowMessagesByInRangeRegularUsers = ?")
    assert(database.inTransaction())

    val val1 = if (allowMessagesByInRangeRegularUsers) { 1L } else { 0L }
    stmt.bindLong(1, val1)

    stmt.execute()
}


from Does Room automatically cache calls to compileStatement?

No comments:

Post a Comment