mdb

package module
v0.0.0-...-b63d30c Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2017 License: BSD-3-Clause Imports: 8 Imported by: 1

README

MDB

MDB is a thin convenience wrapper around the lmdb-go driver for the LMDB database. It simplifies golang code in cases, where you have only one database per LMDB environment.

Documentation

Index

Constants

View Source
const (
	ReadOnly = lmdb.Readonly
)

Variables

This section is empty.

Functions

func CreateKey

func CreateKey(args ...tuple.Element) []byte

Types

type Config

type Config struct {
	EnvFlags uint
	SizeMbs  int64
	Mode     os.FileMode
	MaxDBs   int
}

func NewConfig

func NewConfig() *Config

type DB

type DB struct {
	Env *lmdb.Env
	DBI lmdb.DBI
}

func New

func New(folder string, cfg *Config) (*DB, error)

New creates a new DB wrapper around LMDB

func (*DB) Close

func (db *DB) Close() error

Close the environment

func (*DB) CreateRead

func (db *DB) CreateRead() (tx *Tx, err error)

func (*DB) CreateTransaction

func (db *DB) CreateTransaction(flags uint) (tx *Tx, err error)

func (*DB) CreateWrite

func (db *DB) CreateWrite() (tx *Tx, err error)

func (*DB) Read

func (db *DB) Read(fn TxOp) error

func (*DB) Update

func (db *DB) Update(fn TxOp) error

func (*DB) UpdateLocked

func (db *DB) UpdateLocked(threadLocked bool, fn TxOp) error

type Tx

type Tx struct {
	DB  lmdb.DBI
	Env *lmdb.Env
	Tx  *lmdb.Txn
}

func (*Tx) Close

func (tx *Tx) Close() (err error)

func (*Tx) Commit

func (tx *Tx) Commit() error

func (*Tx) Del

func (tx *Tx) Del(key []byte) error

func (*Tx) DelRange

func (t *Tx) DelRange(key []byte) error

func (*Tx) Get

func (tx *Tx) Get(key []byte) (data []byte, err error)

func (*Tx) GetNext

func (tx *Tx) GetNext(key []byte) (k, v []byte, err error)

func (*Tx) GetPrev

func (tx *Tx) GetPrev(key []byte) (k, v []byte, err error)

func (*Tx) Put

func (tx *Tx) Put(key []byte, val []byte) error

func (*Tx) PutProto

func (tx *Tx) PutProto(key []byte, val proto.Message) error

func (*Tx) PutReserve

func (tx *Tx) PutReserve(key []byte, size int) ([]byte, error)

func (*Tx) ReadProto

func (tx *Tx) ReadProto(key []byte, pb proto.Message) error

func (*Tx) ScanRange

func (tx *Tx) ScanRange(key []byte, row func(k, v []byte) error) error

type TxOp

type TxOp func(tx *Tx) error

Jump to

Keyboard shortcuts

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