Documentation
¶
Overview ¶
Package db defines the interfaces, routine flags and errors shared by the Berkeley DB 1.85 access methods in packages btree, hash and recno, and the ndbm interface in package ndbm.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrNotFound = errors.New("not found") // key not found or no more keys ErrKeyExist = errors.New("key exists") // put with RNoOverwrite ErrInvalid = errors.New("invalid") // bad argument ErrReadOnly = errors.New("read only") // change to read-only database ErrFormat = errors.New("invalid format") // not a database file ErrOverflow = errors.New("out of overflow pages, increase page size") ErrNoPage = fmt.Errorf("%w: no such page", ErrFormat) // link past end of file ErrPageType = fmt.Errorf("%w: page type", ErrFormat) // unexpected page type )
Errors returned by the access methods, to be checked with errors.Is.
Functions ¶
This section is empty.
Types ¶
type DB ¶
type DB interface {
// Close syncs the database and closes its files.
Close() (err error)
// Del deletes key, or with RCursor the entry at the cursor.
Del(key []byte, flag Flag) (err error)
// Fd returns the file descriptor, or ^uintptr(0) for an in-memory
// database.
Fd() (fd uintptr)
// Get returns the data stored under key, or ErrNotFound.
Get(key []byte, flag Flag) (data []byte, err error)
// Put stores data under key and returns the key it is stored under,
// which differs from key only for recno insertions.
Put(key []byte, data []byte, flag Flag) (rkey []byte, err error)
// Sync writes all changes to disk.
Sync(flag Flag) (err error)
// Seq returns the next key/data pair of a sequential scan, or
// ErrNotFound at its end. RFirst, RLast and RCursor start a scan,
// RNext and RPrev continue it.
Seq(key []byte, flag Flag) (rkey []byte, data []byte, err error)
}
DB is an open database, the counterpart of the C DB handle. Implementations are safe for concurrent use: Get calls run in parallel, other methods one at a time; Seq has a single cursor shared by all callers.
type DBM ¶
type DBM interface {
// Close writes changes and closes the file.
Close() (err error)
// Fetch returns the content stored under key, or ErrNotFound.
Fetch(key []byte) (content []byte, err error)
// Store stores content under key. With DBMInsert an existing key is
// kept and ErrKeyExist returned.
Store(key, content []byte, mode Mode) (err error)
// Delete deletes key, or returns ErrNotFound.
Delete(key []byte) (err error)
// FirstKey returns the first key, or ErrNotFound if the database is
// empty.
FirstKey() (key []byte, err error)
// NextKey returns the key after the one returned last, or ErrNotFound
// at the end.
NextKey() (key []byte, err error)
// DirFd returns the file descriptor of the database file.
DirFd() (fd uintptr)
}
DBM is an open ndbm database, the counterpart of the C DBM handle. Implementations are safe for concurrent use; FirstKey and NextKey share a single cursor.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package btree implements the B-Tree access method of Berkeley DB 1.85, reading and writing files compatible with dbopen(3).
|
Package btree implements the B-Tree access method of Berkeley DB 1.85, reading and writing files compatible with dbopen(3). |
|
Package hash implements the hash access method of Berkeley DB 1.85, reading and writing files compatible with dbopen(3).
|
Package hash implements the hash access method of Berkeley DB 1.85, reading and writing files compatible with dbopen(3). |
|
Package hsearch implements the hsearch(3) hash table of Berkeley DB 1.85 on top of an in-memory hash database.
|
Package hsearch implements the hsearch(3) hash table of Berkeley DB 1.85 on top of an in-memory hash database. |
|
internal
|
|
|
dbtest
Package dbtest holds helpers shared by the access method tests.
|
Package dbtest holds helpers shared by the access method tests. |
|
flags
Package flags implements a set of bit flags.
|
Package flags implements a set of bit flags. |
|
lru
Package lru implements a cache evicting least recently used values, approximated by second chance.
|
Package lru implements a cache evicting least recently used values, approximated by second chance. |
|
Package ndbm implements the ndbm(3) interface of Berkeley DB 1.85 on top of a hash database, file compatible with dbm_open(3).
|
Package ndbm implements the ndbm(3) interface of Berkeley DB 1.85 on top of a hash database, file compatible with dbm_open(3). |
|
Package recno implements the record number access method of Berkeley DB 1.85: records of a flat text file addressed by their position.
|
Package recno implements the record number access method of Berkeley DB 1.85: records of a flat text file addressed by their position. |
Click to show internal directories.
Click to hide internal directories.