/store

Go common key-val database API

Primary LanguageGoBSD 2-Clause "Simplified" LicenseBSD-2-Clause

store

Examples

package main

import (
	"fmt"
	"log"
	"os"

	"github.com/vcaesar/store"
)

func main() {
	TestDBName := "test.db"
	db, err := store.Open(TestDBName, "badger")
	if err != nil {
		log.Fatal("Store open: ", err)
	}
	log.Println("db test...")
	os.MkdirAll(TestDBName, 0777)

	err = db.Set([]byte("key1"), []byte("value1"))
	if err != nil {
		fmt.Println("db set: ", err)
	}

	has, err := db.Has([]byte("key1"))
	fmt.Println("db has: ", has, err)

	buf, err := db.Get([]byte("key1"))
	fmt.Println("db get: ", string(buf), err)

	db.Close()
	// os.RemoveAll(TestDBName)
}