goleveldb

package
v0.0.0-...-bdd3411 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2015 License: MIT Imports: 7 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Destroy

func Destroy(path string) error

Destroy destroys the DB at the given path.

func New

func New(db *leveldb.DB) backend.DB

New returns a DB from the given LevelDB instance.

func NewMem

func NewMem() (backend.DB, error)

NewMem creates a new DB backed by memory only (i.e. not persistent)

func Open

func Open(path string) (backend.DB, error)

Open creates or opens an existing DB at the given path.

Types

type Batch

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

Batch represents a set of put/delete operations to perform on a Bucket.

func (*Batch) Close

func (b *Batch) Close()

Close discards this batch.

func (*Batch) Delete

func (b *Batch) Delete(k []byte) error

Delete deletes the key `k`.

func (*Batch) Put

func (b *Batch) Put(k, v []byte) error

Put sets the key `k` to value `v`.

type Bucket

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

Bucket represents a goleveldb-backed queue, where each key is prefixed by the given namespace. All batch writes are synced by default.

func (*Bucket) Batch

func (q *Bucket) Batch(fn func(backend.Batch) error) error

Batch enacts a number of operations in one atomic go. If the batch function returns a non-nil error, the batch is discarded and the error is returned to the caller. If the batch function returns nil, the batch is committed to the queue.

func (*Bucket) Clear

func (q *Bucket) Clear() error

Clear removes all items from this queue.

func (*Bucket) ForEach

func (q *Bucket) ForEach(fn func(k, v []byte) error) error

ForEach iterates through keys in the queue. If the iteration function returns a non-nil error, iteration stops and the error is returned to the caller.

func (*Bucket) Get

func (q *Bucket) Get(k []byte) ([]byte, error)

Get returns the value stored at key `k`.

type DB

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

DB encapsulates a LevelDB instance.

func (*DB) Bucket

func (db *DB) Bucket(name string) (backend.Bucket, error)

Bucket returns a queue in the given namespace.

func (*DB) Close

func (db *DB) Close()

Close closes the database and releases any resources.

Jump to

Keyboard shortcuts

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