You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
persistant serverside error handling on for edge cases.
interactive cli mode, which stores variable-like data (for now only supports values of type string and int) to then be retrieved later with methods like "GET", "SET", "DEL", and "EXIT" to exit the program.
serializes values to bytes before appending to the database struct for optimised performance.
utilises a tcp server for database logic and validation.
usage:
to start off, you can either set data using SetInt() for key-values with values having type int, or SetString() for key-values with values having type string:
package main
import (
"fmt"
"github.com/72sevenzy2/in-memory-database/db"
)
func main() {
v := db.NewDB()
val, ok := v.GetInt("test1")
if ok {
fmt.Println(val)
}
val2, ok2 := v.GetString("test2")
if ok2 {
fmt.Println(val2)
}
}
if you want to retrieve all key-values with values of type strings/ints:
package main
import (
"fmt"
"github.com/72sevenzy2/in-memory-database/db"
)
func main() {
v := db.NewDB()
vals, ok := v.GetAllString() // vals is of type map[string]string
if ok {
for k, v := range vals {
fmt.Println(k, v)
}
}
vals2, ok2 := v.GetAllInt() // vals2 is of type map[string]uint32
if ok2 {
for k, v := range vals2 {
fmt.Println(k, v)
}
}
}
and finally, to delete keys:
package main
import (
"fmt"
"github.com/72sevenzy2/in-memory-database/db"
)
func main() {
v := db.NewDB()
v.Del("keyName")
}
interactive cli tutorial:
run the following to begin:
go run .
and follow up by declarin`g a variable:
SET [KeyName] [Value]
(key names only support either integers or strings as of now).
after setting a variable, you can then retrieve it like so:
GET [KeyName]
and it returns the value of the key given.
to delete a variable/key:
DEL [KeyName]
finally, to exit the program, run:
EXIT
About
k-v database built with go, stores key-values with serialization involved to ensure optimal performance.