Giter Site home page Giter Site logo

sett's Introduction

Sett

A golang package which offers a simple abstraction on BadgerDB key/value store

Based on BadgerDB v1 API. No support for v2 at this time.

API

Creating or opening a store with Sett is identical to BadgerDB

opts := sett.DefaultOptions
opts.Dir = "data"
opts.ValueDir = "data/log"

s := sett.Open(opts)
defer s.Close()

Simple set, get and delete a key. Strings used in preference to byte slices.

s.Set("hello", "world")
s.Get("hello")
s.Delete("hello")

Tables

Tables are virtual, simply a prefix on the key, but formalised through the Sett API. The aim being to make organisation, reasoning and usage, a little simpler.

Add a key/value to "client" table

s.Table("client").Set("hello", "world")

Get value of key from "client" table

s.Table("client").Get("hello")

Delete key and value from "client" table

s.Table("client").Delete("hello")

Drop "client" table including all keys

s.Table("client").Drop()

Batch Set

Uses concurrent goroutines to split the insert payload, default is 500 keys per goroutine. To change this set the sett.BatchSize variable before opening connection.

sett.BatchSize = 50
s := sett.Open(opts)
defer s.Close()

Batch insert into "client" table

s.Batchup("hello", "world")
s.Batchup("hello-again", "world")
s.Batchup("goodbye", "world")

s.Table("client").SetBatch()

Get entire table, or subset of table

Use sett.Scan() to return contents of virtual table or a subset of that table based on a prefix filter.

Retrieving all key/values from the "client" table

scan, _ := s.Table("client").Scan()
for k, v := range scan {
	log.Println(k, v)
}

Using a prefix filter to get a subset of a key/values from "client" table. In the below example the key prefix filter is "hello"

scan, _ := s.Table("client").Scan("hello")
for k, v := range scan {
	log.Println(k, v)
}

sett's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

sett's Issues

Updated?

This is really good ^.^

I was just wondering if you have plans on keeping it updated along with BadgerDB?

I could try and contribute to the code as and when time permits if you're accepting contribution ^.^

not enough arguments in call to item.Value

# github.com/olliephillips/sett
..\github.com\olliephillips\sett\sett.go:72:12: assignment mismatch: 2 variables but 1 values
..\github.com\olliephillips\sett\sett.go:72:24: not enough arguments in call to item.Value
        have ()
        want (func([]byte) error)
..\github.com\olliephillips\sett\sett.go:151:9: assignment mismatch: 2 variables but 1 values
..\github.com\olliephillips\sett\sett.go:151:22: not enough arguments in call to item.Value
        have ()
        want (func([]byte) error)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.