gome_badger

package module
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 5, 2019 License: MIT Imports: 2 Imported by: 1

README

gome_badger

BadgerDB wrapper to simplify the usage

usage examples:

go get github.com/rebelit/gome_badger

basic usage:

//Initialize a new database
d, err := db.New("/tmp/database")
if err != nil{
    fmt.Println("I didn't create a new DB")
}
defer d.Close()


//Add some data to the database
if err := d.Set("coolKey", "coolData"); err != nil{
    fmt.Println("I didn't set any data")
}


//Add some more data to the database
if err := d.Set("coolKey2", "coolData2"); err != nil{
    fmt.Println("I didn't set any data")
}


//Get a single key's value
value, err := d.Get("coolKey")
if err != nil{
    fmt.Println("I didn't get any data")
}
fmt.Println(value)


//Get all keys from the database
keys, err := d.GetAllKeys()
if err != nil{
    fmt.Println("I didn't get any data")
}
for _, k := range keys{
    fmt.Println(k)
}


//Delete a k/v pair from the database
if err := d.Delete("coolKey"); err != nil{
    fmt.Println("I didn't delete any data")
}


//Delete everything
if err := d.DeleteAll(); err != nil{
    fmt.Println("I didn't delete any data")
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Badger

type Badger struct {
	// contains filtered or unexported fields
}

func (Badger) Close

func (d Badger) Close() error

func (Badger) Delete

func (d Badger) Delete(key string) error

func (Badger) DeleteAll

func (d Badger) DeleteAll() error

func (Badger) Get

func (d Badger) Get(key string) (string, error)

func (Badger) GetAllKeys

func (d Badger) GetAllKeys() ([]string, error)

func (Badger) Set

func (d Badger) Set(key string, value string) error

type Database

type Database interface {
	Set(key, value string) error
	Delete(key string) error
	DeleteAll() error
	Get(key string) (string, error)
	GetAllKeys() ([]string, error)
	Close() error
}

func Open

func Open(path string) (Database, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL