leveldb

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2020 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// ErrClosed is an error message returned when the datastore is no longer open
	ErrClosed = errors.New("datastore closed")
)

Functions

This section is empty.

Types

type Datastore

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

Datastore is a go-datastore implement using leveldb

func NewDatastore

func NewDatastore(path string, opts *Options) (*Datastore, error)

NewDatastore returns a new datastore backed by leveldb

for path == "", an in memory backend will be chosen

func (*Datastore) Batch

func (d *Datastore) Batch() (ds.Batch, error)

Batch returns a new levelDB batcher

func (*Datastore) Close

func (d *Datastore) Close() (err error)

Close shuts down leveldb

func (*Datastore) Delete

func (d *Datastore) Delete(key ds.Key) (err error)

Delete removed the key from our datastore

func (*Datastore) DiskUsage

func (d *Datastore) DiskUsage() (du uint64, err error)

DiskUsage returns the current disk size used by this levelDB. For in-mem datastores, it will return 0.

func (*Datastore) Get

func (d *Datastore) Get(key ds.Key) (value []byte, err error)

Get returns the value corresponding to the key

func (*Datastore) GetSize

func (d *Datastore) GetSize(key ds.Key) (size int, err error)

GetSize returns the size of the associated key

func (*Datastore) Has

func (d *Datastore) Has(key ds.Key) (exists bool, err error)

Has returns whether or not we have the key

func (*Datastore) NewTransaction

func (d *Datastore) NewTransaction(readOnly bool) (ds.Txn, error)

NewTransaction returns a new transaction handler

func (*Datastore) Put

func (d *Datastore) Put(key ds.Key, value []byte) (err error)

Put stores a key-value pair in leveldb

func (*Datastore) Query

func (d *Datastore) Query(q dsq.Query) (dsq.Results, error)

Query searches for keys in our datastore

func (*Datastore) Sync

func (d *Datastore) Sync(prefix ds.Key) error

Sync is a noop

type Options

type Options = opt.Options

Options is an alias of syndtr/goleveldb/opt.Options which might be extended in the future.

Jump to

Keyboard shortcuts

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