Documentation ¶
Overview ¶
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 ¶
- Variables
- type Error
- type Item
- type KeyAlreadyExists
- type KeyNotFound
- type NDBM
- func (ndbm *NDBM) Close()
- func (ndbm *NDBM) Delete(key []byte) error
- func (ndbm *NDBM) Fetch(key []byte) ([]byte, error)
- func (ndbm *NDBM) Insert(key, value []byte) error
- func (ndbm *NDBM) Items() []Item
- func (ndbm *NDBM) ItemsCallback(callback func(key, value []byte) error) error
- func (ndbm *NDBM) Keys() [][]byte
- func (ndbm *NDBM) KeysCallback(callback func([]byte) error) error
- func (ndbm *NDBM) Len() int
- func (ndbm *NDBM) LockExclusive() error
- func (ndbm *NDBM) LockShared() error
- func (ndbm *NDBM) Replace(key, value []byte) error
- func (ndbm *NDBM) Unlock() error
- func (ndbm *NDBM) Update(items []Item) error
- func (ndbm *NDBM) Values() [][]byte
- func (ndbm *NDBM) ValuesCallback(callback func([]byte) error) error
Constants ¶
This section is empty.
Variables ¶
var ErrAlreadyLocked = fmt.Errorf("Database is already locked")
ErrAlreadyLocked is returned if another process already has a lock.
Functions ¶
This section is empty.
Types ¶
type Error ¶
type Error struct {
// contains filtered or unexported fields
}
Error is returned on unexpected NDBM or libc errors.
type KeyAlreadyExists ¶
type KeyAlreadyExists struct {
Key []byte
}
KeyAlreadyExists is returned when trying to insert a key that already exists.
func (KeyAlreadyExists) Error ¶
func (err KeyAlreadyExists) Error() string
type KeyNotFound ¶
type KeyNotFound struct {
Key []byte
}
KeyNotFound is returned when trying to fetch or delete a key that doesn't exist.
func (KeyNotFound) Error ¶
func (err KeyNotFound) Error() string
type NDBM ¶
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 ¶
Open lets you specify how the database is opened, for example, if you want read-only mode.
func OpenWithDefaults ¶
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) Delete ¶
Delete deletes an entry from the database. Returns KeyNotFound if the key can't be found.
func (*NDBM) Fetch ¶
Fetch retrieves an entry value by key. Returns KeyNotFound if the key can't be found.
func (*NDBM) Insert ¶
Insert inserts a new entry into the database. Returns KeyAlreadyExists if the key already exists.
func (*NDBM) ItemsCallback ¶
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) KeysCallback ¶
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) LockExclusive ¶
LockExclusive locks the database for a single process.
func (*NDBM) LockShared ¶
LockShared locks the database for multiple processes. For example, multiple readers can share a read-only database.