storage

package
v0.0.0-...-25c57ca Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2018 License: BSD-2-Clause Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ListDrivers

func ListDrivers() []string

Types

type Bucket

type Bucket interface {
	ForEach(func(k, v []byte) error) error

	Cursor() Cursor

	Writable() bool

	Put(key, value []byte) error

	Get(key []byte) []byte

	Delete(key []byte) error
}

Bucket represents a collection of key/value pairs.

type Cursor

type Cursor interface {
	Bucket() Bucket
	// Delete removes the current key/value pair the cursor is at without
	// invalidating the cursor.
	Delete() error
	// First positions the cursor at the first key/value pair and returns
	// whether or not the pair exists.
	First() bool
	// Last positions the cursor at the last key/value pair and returns
	// whether or not the pair exists.
	Last() bool
	// Next moves the cursor one key/value pair forward and returns whether
	// or not the pair exists.
	Next() bool
	// Prev moves the cursor one key/value pair backward and returns whether
	// or not the pair exists.
	Prev() bool
	// Seek positions the cursor at the first key/value pair that is greater
	// than or equal to the passed seek key.  Returns whether or not the
	// pair exists.
	Seek(seek []byte) bool
	// Key returns the current key the cursor is pointing to.
	Key() []byte
	// Value returns the current value the cursor is pointing to.
	Value() []byte
}

Cursor represents a cursor over key/value pairs

type MetaData

type MetaData interface {
	Create(key []byte) (Bucket, error)

	CreateIfNotExists(key []byte) (Bucket, error)

	Get(key []byte) Bucket

	Delete(key []byte) error
}

MetaData represents a collection of Bucket

type Storage

type Storage interface {
	// Type returns the database driver type the current database instance
	Type() string

	Begin(writable bool) (Transaction, error)

	View(fn func(tx Transaction) error) error

	Update(fn func(tx Transaction) error) error

	Close() error
}

type Transaction

type Transaction interface {
	// Metadata returns the top-most bucket for all metadata storage.
	Metadata() MetaData

	HasBlock(hash *crypto.Hash) (bool, error)

	HasBlocks(hashes []crypto.Hash) ([]bool, error)

	FetchBlockHeader(hash *crypto.Hash) ([]byte, error)

	FetchBlockHeaders(hashes []crypto.Hash) ([][]byte, error)

	FetchBlock(hash *crypto.Hash) ([]byte, error)

	FetchBlocks(hashes []crypto.Hash) ([][]byte, error)

	Commit() error

	Rollback() error
}

Directories

Path Synopsis
engine
mem

Jump to

Keyboard shortcuts

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