LokiDB storage engine
go get github.com/hvuhsg/lokidb/engine- storage on disk for consistency
- in-memory LRU cache for read optimization
- deleted keys cleanup for disk space saving
- distribution of keys across multiple files for maximazing file access time
typeKeyValueStoreinterface {
Set(string, []byte) errorGet(string, func(cursor.Cursor) ([]byte, error)) []byteDel(string) boolKeys() []stringFlush()
Search(func(value []byte) bool) ([][]byte, error)
}package main
import (
"fmt""github.com/hvuhsg/lokidb/engine"
)
funcmain() {
filesDir:="./"cacheSize:=20000numberOfFiles:=5db:=engine.New(filesDir, cacheSize, numberOfFiles)
db.Set("name", []byte("mosh"))
db.Set("age", []byte{5})
name:=db.Get("name") // []byte("mosh")fmt.Printf("%s\n", name)
deleted:=db.Del("name") // truename=db.Get("name", nil) // nilfmt.Println(name, deleted)
}