mapDB

package
v0.0.0-...-70a847a Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2018 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ErrKeyDoesNotExist is returned when a key does not exist within the map
	ErrKeyDoesNotExist = errors.Error("key does not exist")
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ForEachFn

type ForEachFn func(key, value string) (end bool)

ForEachFn is used for iterating over map db items

type MapDB

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

MapDB is a simple map database

func New

func New(dir, name string) (mp *MapDB, err error)

New will return a new map db

func (*MapDB) Close

func (m *MapDB) Close() (err error)

Close will close map db

func (*MapDB) Delete

func (m *MapDB) Delete(key string) (err error)

Delete will remove a value for a given key within the DB

func (*MapDB) ForEach

func (m *MapDB) ForEach(fn ForEachFn) (ended bool)

ForEach will iterate through all the values within the DB

func (*MapDB) Get

func (m *MapDB) Get(key string) (value string, err error)

Get will retrieve a value from the DB

func (*MapDB) Put

func (m *MapDB) Put(key, value string) (err error)

Put will set a value for a given key within the DB

func (*MapDB) Txn

func (m *MapDB) Txn(fn func(*Txn) error) (err error)

Txn will begin a new transaction

type Txn

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

Txn is a MapDB transaction

func (*Txn) Delete

func (t *Txn) Delete(key string) (err error)

Delete will delete a value

func (*Txn) Get

func (t *Txn) Get(key string) (value string, err error)

Get will get a value

func (*Txn) Put

func (t *Txn) Put(key, value string) (err error)

Put will put a value

Jump to

Keyboard shortcuts

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