memdb

package
v0.0.0-...-67646e2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 8, 2020 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

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

DB is an in-memory key/value database.

func New

func New(initBlockSize int) *DB

New creates a new initialized in-memory key/value DB. The initBlockSize is the size of first block. This DB is append-only, deleting an entry would remove entry node but not reclaim KV buffer.

func (*DB) Delete

func (db *DB) Delete(key []byte) bool

Delete deletes the value for the given key. It returns false if the DB does not contain the key.

func (*DB) Get

func (db *DB) Get(key []byte) []byte

Get gets the value for the given key. It returns nil if the DB does not contain the key.

func (*DB) Len

func (db *DB) Len() int

Len returns the number of entries in the DB.

func (*DB) NewIterator

func (db *DB) NewIterator() Iterator

NewIterator returns a new Iterator for the lock store.

func (*DB) Put

func (db *DB) Put(key []byte, v []byte) bool

Put sets the value for the given key. It overwrites any previous value for that key.

func (*DB) Reset

func (db *DB) Reset()

Reset resets the DB to initial empty state. Release all blocks except the initial one.

func (*DB) Size

func (db *DB) Size() int

Size returns sum of keys and values length. Note that deleted key/value will not be accounted for, but it will still consume the buffer, since the buffer is append only.

type Iterator

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

Iterator iterates the entries in the DB.

func (*Iterator) Key

func (it *Iterator) Key() []byte

Key returns the key at the current position.

func (*Iterator) Next

func (it *Iterator) Next()

Next moves the iterator to the next entry.

func (*Iterator) Prev

func (it *Iterator) Prev()

Prev moves the iterator to the previous entry.

func (*Iterator) Seek

func (it *Iterator) Seek(seekKey []byte)

Seek locates the iterator to the first entry with a key >= seekKey.

func (*Iterator) SeekForExclusivePrev

func (it *Iterator) SeekForExclusivePrev(target []byte)

SeekForExclusivePrev locates the iterator to the last entry with key < target.

func (*Iterator) SeekForPrev

func (it *Iterator) SeekForPrev(target []byte)

SeekForPrev locates the iterator to the last entry with key <= target.

func (*Iterator) SeekToFirst

func (it *Iterator) SeekToFirst()

SeekToFirst locates the iterator to the first entry.

func (*Iterator) SeekToLast

func (it *Iterator) SeekToLast()

SeekToLast locates the iterator to the last entry.

func (*Iterator) Valid

func (it *Iterator) Valid() bool

Valid returns true if the iterator is positioned at a valid node.

func (*Iterator) Value

func (it *Iterator) Value() []byte

Value returns value.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL