Search and commands

↑ ↓ to select · Enter to open · Esc to close

Type to search packages.

prefixdb

v1.21.5
github.com/luxfi/database/prefixdb

Documentation

pkg.go.dev ↗

Table of contents

↓ to select · Enter to jump· Shift+Enter for source

19 matches

Top ↑

Types

Database

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

Database partitions a database into a sub-database by prefixing all keys with a unique value.

New

func New(prefix []byte, db database.Database) *Database

New returns a new prefixed database.

NewNested

func NewNested(prefix []byte, db database.Database) *Database

Deprecated: Use New instead.

Database.Backup

func (p *Database) Backup(w io.Writer, since uint64) (uint64, error)

Database.Close

func (p *Database) Close() error

Close implements the database.Database interface.

Database.Compact

func (p *Database) Compact(start, limit []byte) error

Compact implements the database.Database interface.

Database.Delete

func (p *Database) Delete(key []byte) error

Delete implements the database.Database interface.

Database.Get

func (p *Database) Get(key []byte) ([]byte, error)

Get implements the database.Database interface.

Database.Has

func (p *Database) Has(key []byte) (bool, error)

Has implements the database.Database interface.

Database.HealthCheck

func (p *Database) HealthCheck(ctx context.Context) (interface{}, error)

HealthCheck implements the database.Database interface.

Database.Load

func (p *Database) Load(r io.Reader) error

Database.NewBatch

func (p *Database) NewBatch() database.Batch

NewBatch implements the database.Database interface.

Database.NewIterator

func (p *Database) NewIterator() database.Iterator

NewIterator implements the database.Database interface.

Database.NewIteratorWithPrefix

func (p *Database) NewIteratorWithPrefix(prefix []byte) database.Iterator

NewIteratorWithPrefix implements the database.Database interface.

Database.NewIteratorWithStart

func (p *Database) NewIteratorWithStart(start []byte) database.Iterator

NewIteratorWithStart implements the database.Database interface.

Database.NewIteratorWithStartAndPrefix

func (p *Database) NewIteratorWithStartAndPrefix(start, prefix []byte) database.Iterator

NewIteratorWithStartAndPrefix implements the database.Database interface.

prefixedStart MUST be derived only when the caller supplied a start: a nil start means "begin at the prefix", and the underlying store seeks to the prefix itself. Synthesizing start = p.prefix for a nil start would seek the underlying iterator to the FRONT of this partition (p.prefix), which sorts BEFORE p.prefix+prefix; with intervening keys under other sub-prefixes a store that stops at the first non-matching key after a start-seek (zapdb) then returns zero rows for a prefix that does exist. Each prefixed key is also built in its OWN buffer (prefixKey) so the two never alias p.prefix's backing array.

Database.Put

func (p *Database) Put(key, value []byte) error

Put implements the database.Database interface.

Database.Sync

func (p *Database) Sync() error

Sync implements the database.Syncer interface by delegating to the underlying database.

Dependency graph