Skip to content

lokidb/engine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

lokidb engine

LokiDB storage engine

Test Bring 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

type KeyValueStore interface {
    Set(string, []byte) error
    Get(string, func(cursor.Cursor) ([]byte, error)) []byte
    Del(string) bool
    Keys() []string
    Flush()
    Search(func(value []byte) bool) ([][]byte, error)
}

Example

package main

import (
	"fmt"

	"github.com/hvuhsg/lokidb/engine"
)

func main() {
	filesDir := "./"
	cacheSize := 20000
	numberOfFiles := 5

	db := 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")  // true
	
	name = db.Get("name", nil) // nil
	fmt.Println(name, deleted)
}

About

LokiDB storage engine

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages