go-ndbm: github.com/SteelPangolin/go-ndbm Index | Files

package ndbm

import "github.com/SteelPangolin/go-ndbm"

State of the art structured storage for 1986.

ndbm is a Go wrapper around the POSIX NDBM database interface. NDBM is built into Mac OS X and FreeBSD, and is available as a compatibility mode of the GDBM library on Linux.

Index

Package Files

ndbm.go ndbm_nonposix.go

Variables

var ErrAlreadyLocked = fmt.Errorf("Database is already locked")

ErrAlreadyLocked is returned if another process already has a lock.

type Error Uses

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

Error is returned on unexpected NDBM or libc errors.

func (Error) Error Uses

func (err Error) Error() string

type Item Uses

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

Item is a database entry.

type KeyAlreadyExists Uses

type KeyAlreadyExists struct {
    Key []byte
}

KeyAlreadyExists is returned when trying to insert a key that already exists.

func (KeyAlreadyExists) Error Uses

func (err KeyAlreadyExists) Error() string

type KeyNotFound Uses

type KeyNotFound struct {
    Key []byte
}

KeyNotFound is returned when trying to fetch or delete a key that doesn't exist.

func (KeyNotFound) Error Uses

func (err KeyNotFound) Error() string

type NDBM Uses

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

NDBM or compatible database. NDBM is not required by POSIX to be threadsafe, so this library isn't either.

func Open Uses

func Open(path string, flags, mode int) (*NDBM, error)

Open lets you specify how the database is opened, for example, if you want read-only mode.

func OpenWithDefaults Uses

func OpenWithDefaults(path string) (*NDBM, error)

OpenWithDefaults opens an NDBM database in read-write mode and will create it if it doesn't exist with permissions ug=rw,o=.

func (*NDBM) Close Uses

func (ndbm *NDBM) Close()

Close closes the NDBM database.

func (*NDBM) Delete Uses

func (ndbm *NDBM) Delete(key []byte) error

Delete deletes an entry from the database. Returns KeyNotFound if the key can't be found.

func (*NDBM) Fetch Uses

func (ndbm *NDBM) Fetch(key []byte) ([]byte, error)

Fetch retrieves an entry value by key. Returns KeyNotFound if the key can't be found.

func (*NDBM) Insert Uses

func (ndbm *NDBM) Insert(key, value []byte) error

Insert inserts a new entry into the database. Returns KeyAlreadyExists if the key already exists.

func (*NDBM) Items Uses

func (ndbm *NDBM) Items() []Item

Items returns every entry in the database.

func (*NDBM) ItemsCallback Uses

func (ndbm *NDBM) ItemsCallback(callback func(key, value []byte) error) error

ItemsCallback executes a callback function for every entry in the database. The callback should take a key and value and return an error if there is a problem.

func (*NDBM) Keys Uses

func (ndbm *NDBM) Keys() [][]byte

Keys lists every key in the database.

func (*NDBM) KeysCallback Uses

func (ndbm *NDBM) KeysCallback(callback func([]byte) error) error

KeysCallback executes a callback function for every key in the database. The callback should take a key and return an error if there is a problem.

func (*NDBM) Len Uses

func (ndbm *NDBM) Len() int

Len returns the number of entries in the database.

func (*NDBM) LockExclusive Uses

func (ndbm *NDBM) LockExclusive() error

LockExclusive locks the database for a single process.

func (*NDBM) LockShared Uses

func (ndbm *NDBM) LockShared() error

LockShared locks the database for multiple processes. For example, multiple readers can share a read-only database.

func (*NDBM) Replace Uses

func (ndbm *NDBM) Replace(key, value []byte) error

Replace inserts a new entry or overwrites an existing entry.

func (*NDBM) Unlock Uses

func (ndbm *NDBM) Unlock() error

Unlock unlocks the database.

func (*NDBM) Update Uses

func (ndbm *NDBM) Update(items []Item) error

Update takes a list of entries and upserts them into the database.

func (*NDBM) Values Uses

func (ndbm *NDBM) Values() [][]byte

Values returns every value in the database.

func (*NDBM) ValuesCallback Uses

func (ndbm *NDBM) ValuesCallback(callback func([]byte) error) error

ValuesCallback executes a callback function for every value in the database. The callback should take a value and return an error if there is a problem.

Package ndbm imports 5 packages (graph). Updated 2016-07-22. Refresh now. Tools for package owners.