13

goukv - an abstraction layer for golang based key-value stores

 4 years ago
source link: https://github.com/alash3al/goukv
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Overview

goukv is an abstraction layer for golang based key-value stores, it is easy to add any backend provider.

Available Providers

Why

I just built this to be used in my side projects, but you can use it with no worries, it is production ready, and I'm open for any idea & contribution.

Backend Stores Rules

just keep it simple stupid!
  • Use the map[string]interface{} as your options.
  • Nil value means DELETE .
  • Respect the Entry struct.
  • Respect the ScanOpts struct.

Example

package main

import (
    "time"
    "fmt"
    "github.com/alash3al/goukv" 
    _ "github.com/alash3al/goukv/providers/goleveldb"
)

func main() {
    db, err := goukv.Open("goleveldb", map[string]interface{}{
        "path": "./db",
    })

    if err != nil {
        panic(err.Error())
    }

    defer db.Close()

    db.Put(goukv.Entry{
        Key: []byte("k1"),
        Value: []byte("v1"),
        TTL: time.Second * 10,
    })

    fmt.Println(db.Get([]byte("k1")))
}

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK