backend

package
v0.0.0-...-c86579f Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2016 License: ISC Imports: 6 Imported by: 0

Documentation

Overview

Package backend implements the persistent AzmoDB backend key/value database.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backend

type Backend interface {
	// Range performs fn on all values stored in the database at rev.
	// If fn returns an errors the traversal is stopped and the error
	// is returned.
	Range(rev Revision, fn func(key []byte, value []byte) error) error

	// Batch starts a new batch transaction. Starting multiple write
	// batch transactions will cause the calls to block and be
	// serialized until the current write batch transaction finishes.
	Batch(rev Revision) (Batch, error)

	// Last returns the last revision in the database and an error if
	// any.
	Last() (Revision, error)
}

Backend represents a persistent AzmoDB backend.

type Batch

type Batch interface {
	// Put sets the value for a key in the database. Put must create a
	// copy of the supplied key and value.
	Put(key []byte, value []byte) error

	// Close closes the batch transaction.
	Close() error
}

Batch returns a batch transaction on the database.

type DB

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

DB represents the default AzmoDB backend. DB represents a collection of buckets persisted to a file on disk. All data access is performed through transactions which can be obtained through the DB.

func Open

func Open(path string, timeout time.Duration, opts ...Option) (*DB, error)

Open creates and opens a database at the given path. If the file does not exist then it will be created automatically.

Timeout is the amount of time to wait to obtain a file lock. When set to zero it will wait indefinitely. This option is only available on Darwin and Linux.

func (*DB) Batch

func (db *DB) Batch(rev Revision) (Batch, error)

Batch starts a new batch transaction. Starting multiple write batch transactions will cause the calls to block and be serialized until the current write batch transaction finishes.

func (*DB) Close

func (db *DB) Close() error

Close releases all database resources. All batch transactions must be closed before closing the database.

func (*DB) Last

func (db *DB) Last() (rev Revision, err error)

Last returns the last revision in the database and an error if any.

func (*DB) Range

func (db *DB) Range(rev Revision, fn func(key, value []byte) error) error

Range performs fn on all values stored in the database at rev. If fn returns an errors the traversal is stopped and the error is returned.

func (*DB) WriteTo

func (db *DB) WriteTo(w io.Writer) (n int64, err error)

WriteTo writes the entire database to a writer.

type Option

type Option func(*DB) error

Option represents a DB option function.

func WithMaxBatchEntries

func WithMaxBatchEntries(entries int) Option

WithMaxBatchEntries configures the maximum batch entries.

func WithMaxBatchSize

func WithMaxBatchSize(size int) Option

WithMaxBatchSize configures the maximum batch size.

type Revision

type Revision [8]byte

Revision represents a serialized AzmoDB revision.

Jump to

Keyboard shortcuts

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