commonMain.org.kodein.db.impl.AbstractDBFactory.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of kodein-db Show documentation
Show all versions of kodein-db Show documentation
Kodein-DB implementation library
The newest version!
package org.kodein.db.impl
import org.kodein.db.*
import org.kodein.db.impl.model.cache.defaultCacheCopyMaxSize
import org.kodein.db.impl.model.cache.defaultCacheSize
import org.kodein.db.impl.model.cache.middleware
import org.kodein.db.model.ModelDB
import org.kodein.db.model.cache.ModelCache
public abstract class AbstractDBFactory : DBFactory {
protected abstract val mdbFactory: DBFactory
override fun open(path: String, vararg options: Options.Open): DB {
val mdbOptions = if (options() == null) {
val middleware = ModelCache.middleware(
maxSize = options()?.maxSize ?: defaultCacheSize,
copyMaxSize = options()?.maxSize ?: defaultCacheCopyMaxSize(),
hashCodeImmutabilityChecks = options() == null
)
arrayOf(Middleware.Model(middleware)) + options
} else {
options
}
val mdb = mdbFactory.open(path, *mdbOptions)
return DBImpl(mdb)
}
override fun destroy(path: String, vararg options: Options.Open) {
mdbFactory.destroy(path, *options)
}
}