storage

package
v0.0.0-...-9a529fd Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2017 License: MIT Imports: 7 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Interface

type Interface interface {
	// Read retrieves a slice of entries from the storage. The output is a slice of the same type as
	// of `shape`, possibly of length 0.
	// The provided type has to implement a binary.Unmarshaler interface
	Read(key []byte, shape encoding.BinaryUnmarshaler, buckets ...[]byte) (interface{}, error)
	// ReadAll goes through each key of a bucket and return a slice of all values. This implies
	// therefore that all values in each key are of the same type (the shape provided)
	ReadAll(shape encoding.BinaryUnmarshaler, buckets ...[]byte) (interface{}, error)
	// Update replaces a set of entries by the new given set
	Update(key []byte, entries []encoding.BinaryMarshaler, buckets ...[]byte) error
	// Append adds at the end of an existing set the new given set
	Append(key []byte, entries []encoding.BinaryMarshaler, buckets ...[]byte) error
	// Delete complete removes all targeted entries
	Delete(key []byte, buckets ...[]byte) error
	// Reset empties a bucket
	Reset(buckets ...[]byte) error
	// Close terminates the communication with the storage
	Close() error
}

The storage Interface provides an abstraction on top of the bolt database to store and access data in a local in-memory database. All methods uses a slice of buckets as bucket selector, each subsequent bucket being nested in the previous one. Each time also, the key can be omitted in which case it will fall back to a default key.

func New

func New(name string) (Interface, error)

New creates a new storage instance ready-to-be-used

Jump to

Keyboard shortcuts

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