Skip to content

Repository files navigation

lokidb engine

LokiDB storage engine

TestBring Them Home


Import

go get github.com/hvuhsg/lokidb/engine

Features

  • 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

Interface

typeKeyValueStoreinterface {
Set(string, []byte) errorGet(string, func(cursor.Cursor) ([]byte, error)) []byteDel(string) boolKeys() []stringFlush()
Search(func(value []byte) bool) ([][]byte, error)
}

Example

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)
}

About

LokiDB storage engine

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages