database

package
v1.4.3 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2024 License: GPL-3.0 Imports: 6 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
}

func New

func New(engine DBPutGetDeleter) (*DB, error)

New creates a new instance of a database.

func (*DB) Close

func (d *DB) Close() error

Close the database engine.

func (*DB) Delete added in v1.1.29

func (d *DB) Delete(key []byte) error

Delete a record from the db.

func (*DB) Get

func (d *DB) Get(key []byte) ([]byte, error)

Get a record based on key.

func (*DB) NewIterator

func (d *DB) NewIterator(slice *util.Range, ro *opt.ReadOptions) iterator.Iterator

NewIterator creates a new database iterator.

func (*DB) Put

func (d *DB) Put(key, value []byte) error

Put a record into the db.

func (*DB) Write

func (d *DB) Write(batch *leveldb.Batch, wo *opt.WriteOptions) error

Write batch write.

type DBPutGetDeleter added in v1.1.29

type DBPutGetDeleter interface {
	Get(key []byte, ro *opt.ReadOptions) (value []byte, err error)
	Put(key, value []byte, wo *opt.WriteOptions) error
	Close() error
	Write(batch *leveldb.Batch, wo *opt.WriteOptions) error
	NewIterator(slice *util.Range, ro *opt.ReadOptions) iterator.Iterator
	Delete(key []byte, wo *opt.WriteOptions) error
}

DBPutGetDeleter represents a database engine. TODO: refactor the logic with Database they are almost the same

type Database

type Database interface {
	Put(key, value []byte) error
	Get(key []byte) ([]byte, error)
	Close() error
	Write(batch *leveldb.Batch, wo *opt.WriteOptions) error
	NewIterator(slice *util.Range, ro *opt.ReadOptions) iterator.Iterator
	Delete(key []byte) error
}

Database represents the database functionalities.

Jump to

Keyboard shortcuts

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