Add simple Dao to persistently store key, value pairs
This commit is contained in:
parent
7efeb9bace
commit
74c2f643f9
|
@ -37,6 +37,7 @@ dependencies {
|
|||
implementation("com.moandjiezana.toml:toml4j:0.7.2")
|
||||
implementation(kotlin("stdlib-jdk8"))
|
||||
implementation("org.javacord:javacord:3.0.4")
|
||||
implementation("org.mapdb:mapdb:3.0.7")
|
||||
|
||||
testImplementation("io.kotlintest:kotlintest-runner-junit5:3.3.2")
|
||||
testImplementation("io.mockk:mockk:1.9.3")
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
package moe.kageru.kagebot.persistence
|
||||
|
||||
import org.mapdb.DBMaker
|
||||
import org.mapdb.Serializer
|
||||
|
||||
object Dao {
|
||||
private val db = DBMaker.fileDB("kagebot.db").fileMmapEnable().closeOnJvmShutdown().make()
|
||||
private val strings = db.hashMap("main", Serializer.STRING, Serializer.STRING).createOrOpen()
|
||||
|
||||
fun store(key: String, value: String) {
|
||||
strings[key] = value
|
||||
}
|
||||
|
||||
fun get(key: String): String? {
|
||||
return strings[key]
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user