https://github.com/72sevenzy2/in-memory-database
k-v database built with go, stores key-values with serialization involved to ensure optimal performance.
https://github.com/72sevenzy2/in-memory-database
cli-tool go golang golang-cli golang-database golang-package in-memory-database
Last synced: 28 days ago
JSON representation
k-v database built with go, stores key-values with serialization involved to ensure optimal performance.
- Host: GitHub
- URL: https://github.com/72sevenzy2/in-memory-database
- Owner: 72sevenzy2
- License: mit
- Created: 2026-05-04T09:34:47.000Z (about 2 months ago)
- Default Branch: main
- Last Pushed: 2026-05-30T10:09:07.000Z (28 days ago)
- Last Synced: 2026-05-30T11:23:28.106Z (28 days ago)
- Topics: cli-tool, go, golang, golang-cli, golang-database, golang-package, in-memory-database
- Language: Go
- Homepage:
- Size: 59.6 KB
- Stars: 2
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
key-value style in-memory database.
- persistant error handling 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.
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()
err := v.SetInt("test1", 200) // setting ints
if err != nil {
panic(err)
}
err2 := v.SetString("test2", "hello") // setting strings
if err2 != nil {
panic(err2)
}
}
```
afterwards, you may retrieve them like so:
```
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")
}
```