import "github.com/robaho/keydb"
database.go diskio.go disksegment.go errors.go memorysegment.go merger.go multisegment.go segment.go transaction.go tree.go
The functions finds all nodes within the provided key range, call function fn on each found node
returns nil if the path points to a valid database or empty directory
remove the database, deleting all files. the caller must be able to gain exclusive multi to the database
a Database reference is obtained via Open()
open a database. The database can only be opened by a single process, but the *Database reference can be shared across Go routines. The path is a directory name. if createIfNeeded is true, them if the db doesn't exist it will be created Additional tables can be added on subsequent opens, but there is no current way to delete a table, except for deleting the table related files from the directory
func (db *Database) BeginTX(table string) (*Transaction, error)
create a transaction for a database table. a Transaction can only be used by a single Go routine. each transaction should be completed with either Commit, or Rollback
close the database. any memory segments are persisted to disk. The resulting segments are merged until the default maxSegments is reached
close the database with control of the segment count. if segmentCount is 0, then the merge process is skipped
type LookupIterator interface {
// returns EndOfIterator when complete, if err is nil, then key and value are valid
Next() (key []byte, value []byte, err error)
// contains filtered or unexported methods
}iterator interface for table scanning. all iterators should be read until completion
type Transaction struct {
// contains filtered or unexported fields
}func (tx *Transaction) Commit() error
persist any changes to the table. after Commit the transaction can no longer be used
func (tx *Transaction) CommitSync() error
persist any changes to the table. waiting for disk segment to be created. note that synchronous writes are not used, so that a hard OS failure could leave the database in a corrupted state. after Commit the transaction can no longer be used
func (tx *Transaction) Get(key []byte) (value []byte, err error)
retrieve a value from the table
func (tx *Transaction) GetID() uint64
func (tx *Transaction) Lookup(lower []byte, upper []byte) (LookupIterator, error)
find matching record between lower and upper inclusive. lower or upper can be nil and then the range is unbounded on that side. Using the iterator after the transaction has been Commit/Rollback is not supported.
func (tx *Transaction) Put(key []byte, value []byte) error
put a value into the table. empty keys are not supported.
func (tx *Transaction) Remove(key []byte) ([]byte, error)
remove a key and its value from the table. empty keys are not supported.
func (tx *Transaction) Rollback() error
discard any changes to the table. after Rollback the transaction can no longer be used
type Tree struct {
// contains filtered or unexported fields
}auto balancing binary Tree, based on code from 'applied go', but modified for []byte key and values, and range searching
return the value for a key, ok is true if the key was found
remove the value for a key, returning it. ok is true if the node existed and was found. If the key was not found a 'nil' value is inserted into the tree
a node returned by FindNodes
| Path | Synopsis |
|---|---|
| _examples |
Package keydb imports 16 packages (graph) and is imported by 1 packages. Updated 2018-09-21. Refresh now. Tools for package owners.