mdb

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

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

Go to latest
Published: Apr 2, 2021 License: BSD-3-Clause Imports: 12 Imported by: 0

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

func NewDbWithKeys

func NewDbWithKeys(t *testing.T, keys []tuple.Tuple) (*DB, *Tx)

func NewDbWithRange

func NewDbWithRange(t *testing.T, max int) (*DB, *Tx)

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, dbiName string, cfg *Config) (*DB, error)

New creates a new DB wrapper around LMDB

func NewDB

func NewDB(t *testing.T) *DB

func TestLMDB

func TestLMDB(t testing.TB) (*DB, func())

TestLMDB creates new instance of *mdb.DB, for test purposes

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 KeyValue

type KeyValue struct {
	Key   []byte
	Value []byte
}

type Queue

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

func NewQueue

func NewQueue(db *DB) *Queue

func (*Queue) Dequeue

func (q *Queue) Dequeue() (element interface{}, err error)

func (*Queue) Enqueue

func (q *Queue) Enqueue(elements ...interface{}) error

func (*Queue) Size

func (q *Queue) Size() (size uint64, err error)

type RangeOptions

type RangeOptions struct {
	Limit   int
	Reverse bool
}

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) Decrement

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

func (*Tx) Del

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

func (*Tx) DelRange

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

func (*Tx) FirstFromRange

func (tx *Tx) FirstFromRange(key []byte) (k []byte, v interface{}, err 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) GetRange

func (tx *Tx) GetRange(key []byte, opt RangeOptions) (kvs []KeyValue, err error)

func (*Tx) Increment

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

func (*Tx) Put

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

func (*Tx) PutGob

func (tx *Tx) PutGob(key []byte, obj interface{}) 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) ReadGob

func (tx *Tx) ReadGob(key []byte, obj interface{}) 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