Add refresh-views command

Signed-off-by: Graham <gpe@openrs2.org>
bzip2
Graham 4 years ago
parent 604ba00154
commit 23bb1ef13c
  1. 3
      archive/src/main/kotlin/org/openrs2/archive/cache/CacheCommand.kt
  2. 12
      archive/src/main/kotlin/org/openrs2/archive/cache/CacheImporter.kt
  3. 16
      archive/src/main/kotlin/org/openrs2/archive/cache/RefreshViewsCommand.kt

@ -9,7 +9,8 @@ public class CacheCommand : NoOpCliktCommand(name = "cache") {
DownloadCommand(), DownloadCommand(),
ImportCommand(), ImportCommand(),
ImportMasterIndexCommand(), ImportMasterIndexCommand(),
ExportCommand() ExportCommand(),
RefreshViewsCommand()
) )
} }
} }

@ -824,6 +824,18 @@ public class CacheImporter @Inject constructor(
} }
} }
public suspend fun refreshViews() {
database.execute { connection ->
connection.prepareStatement(
"""
REFRESH MATERIALIZED VIEW CONCURRENTLY master_index_stats
""".trimIndent()
).use { stmt ->
stmt.execute()
}
}
}
public companion object { public companion object {
private val logger = InlineLogger() private val logger = InlineLogger()

@ -0,0 +1,16 @@
package org.openrs2.archive.cache
import com.github.ajalt.clikt.core.CliktCommand
import com.google.inject.Guice
import kotlinx.coroutines.runBlocking
import org.openrs2.archive.ArchiveModule
import org.openrs2.inject.CloseableInjector
public class RefreshViewsCommand : CliktCommand(name = "refresh-views") {
override fun run(): Unit = runBlocking {
CloseableInjector(Guice.createInjector(ArchiveModule)).use { injector ->
val importer = injector.getInstance(CacheImporter::class.java)
importer.refreshViews()
}
}
}
Loading…
Cancel
Save