high-performance persisted data - made sweet - for the JVM
APACHE-2.0 License
high-performance persisted data - made sweet - for the JVM
datasugar
is a sweet & simple library that can acts as a layer between your primary storage and applications.
Underneath the hood, datasugar
uses memory-mapped files (virtual memory) to provide a persisted data map with
system-memory level write/read times. All data is persisted to disk by your kernel, and is safe in the event something
goes wrong, such as an application crash. A single datasugar
directory can be safely used concurrently by a multitude
of processes on the same machine.
object Server : Database("server") {
object Players : Table("players") {
val uid by autoInc.int().primary()
var username by string(50).unique()
var x by short()
var y by short()
var z by byte()
}
}
Server.Players(123) {
println("uid=$uid, username=$username, position=($x, $y, $z)")
}
Server.Players(123) {
username = "jire"
x = 3222
y = 3222
}
The final step is setup your Database
by specifying a directory:
Server.setup("data/server")
Synchronizing your Database
with an SQL database is sweet & simple:
Server.setup("data/server") {
postgresql { // or "mysql5", "mysql8"
host = "localhost"
port = 3306
username = "root"
password = "sweetdata"
}
}