Documentation ¶
Overview ¶
Package gkvdb provides a lightweight, embeddable and persistent key-value database.
Index ¶
- Constants
- type DB
- func (db *DB) Begin(update bool) *TX
- func (db *DB) Close() error
- func (db *DB) Delete(key []byte) error
- func (db *DB) Get(key []byte) (value []byte)
- func (db *DB) Iterate(prefix []byte, f func(key, value []byte) bool)
- func (db *DB) IterateAsc(prefix []byte, f func(key, value []byte) bool)
- func (db *DB) IterateDesc(prefix []byte, f func(key, value []byte) bool)
- func (db *DB) Options() *Options
- func (db *DB) Set(key []byte, value []byte, ttl ...time.Duration) (err error)
- func (db *DB) SetOptions(options Options) error
- func (db *DB) SetPath(path string) error
- func (db *DB) Size() int64
- type Options
- type TX
- func (tx *TX) Commit() error
- func (tx *TX) Delete(key []byte) error
- func (tx *TX) Get(key []byte) (value []byte)
- func (tx *TX) Iterate(prefix []byte, f func(key, value []byte) bool)
- func (tx *TX) IterateAsc(prefix []byte, f func(key, value []byte) bool)
- func (tx *TX) IterateDesc(prefix []byte, f func(key, value []byte) bool)
- func (tx *TX) Rollback()
- func (tx *TX) Set(key []byte, value []byte, ttl ...time.Duration) error
Constants ¶
const (
// Default instance name.
DEFAULT_NAME = "default"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
func Instance ¶
Instance returns an instance of DB with specified name. The <name> param is unnecessary, if <name> is not passed, it returns a instance with default name.
func (*DB) Delete ¶
Delete removed data specified by <key> from current db.
func (*DB) Get ¶
Get returns the value with given key. It returns nil if <key> is not found in the db.
func (*DB) Iterate ¶
Iterate is alias of IterateAsc. See IterateAsc.
func (*DB) IterateAsc ¶
IteratorAsc iterates the db in ascending order with given callback function <f> starting from <seek>. If <seek> is nil it iterates from the beginning of the db. If <f> returns true, then it continues iterating; or false to stop.
func (*DB) IterateDesc ¶
IteratorDesc iterates the db in descending order with given callback function <f> starting from <seek>. If <prefix> is nil it iterates from the beginning of the db. If <f> returns true, then it continues iterating; or false to stop.
func (*DB) Options ¶
Options return the options of current db object.
func (*DB) Set ¶
Set sets <key>-<value> pair data to current db with <ttl>. The <ttl> is optional, which is not expired in default.
func (*DB) SetOptions ¶
SetOptions sets the options for db.
func (*DB) SetPath ¶
SetPath sets the storage folder path for db.
type Options ¶
type TX ¶
type TX struct {
// contains filtered or unexported fields
}
TX is the transaction object for db.
func (*TX) Commit ¶
Commit commits the changes and close the transaction.
func (*TX) Delete ¶
Delete removed data specified by <key> from current db in this transaction.
func (*TX) Get ¶
Get returns the value with given key in this transaction. It returns nil if <key> is not found in the db.
func (*TX) Iterate ¶
Iterate is alias of IterateAsc. See IterateAsc.
func (*TX) IterateAsc ¶
IteratorAsc iterates the db in ascending order with given callback function <f> starting from <prefix>. If <seek> is nil it iterates from the beginning of the db. If <f> returns true, then it continues iterating; or false to stop.
func (*TX) IterateDesc ¶
IteratorDesc iterates the db in descending order with given callback function <f> starting from <prefix>. If <seek> is nil it iterates from the beginning of the db. If <f> returns true, then it continues iterating; or false to stop.