Skip to content
/ fskv Public

Simple file system based key-value storage for Golang

License

Notifications You must be signed in to change notification settings

nickalie/fskv

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Golang Binary Wrapper

codecov Codacy Badge Go Report Card

Install

go get -u github.com/nickalie/fskv

Example of usage

Storage is safe to be used in multi-thread and multi-process environments.

package main

import (
	"github.com/nickalie/fskv"
	"log"
	"fmt"
)

func main()  {
	db, err := fskv.NewFSKV("data")

	if err != nil {
		log.Fatal(err)
	}

	db.Set("mykey", []byte("somevalue"))

	value, _ := db.Get("mykey")

	fmt.Println("Got: " + string(value))
}

Buckets

Buckets are collections of key/value pairs within the storage. You can create any amount of nested buckets

bucket, _ := db.GetBucket("mybucket")
bucket.Set("some_key", []byte("some_value"))
value, _ := bucket.Get("another_key")
childBucket, := bucket.GetBucket("childbucket")

Iterating

To iterate over the keys:

db.Scan("", func(key string, value []byte) bool {
		fmt.Printf("key: %s, value: %s\n", key, string(value))
		return false
	})

You can specify prefix to iterate over keys with that prefix.

About

Simple file system based key-value storage for Golang

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages