storage

package
v2.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2020 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AlreadyExists

type AlreadyExists struct {
	Entity string
}

func (AlreadyExists) Error

func (e AlreadyExists) Error() string

type Bucket

type Bucket interface {
	KeyValue
	Cursor() Cursor
}

Bucket represents a collection of key/value pairs

type Cursor

type Cursor interface {
	First() (key string, value []byte)
	Last() (key string, value []byte)
	Next() (key string, value []byte)
	Prev() (key string, value []byte)
	// Seek moves the cursor to a seek key and returns it,
	// If the key does not exist then then next key is used.
	// If there are no keys, an empty key is returned
	Seek(seek string) (key string, value []byte)
	// Delete removes current key-value
	Delete() error
	// HasNext returns true if next element exists
	HasNext() bool
}

type KeyValue

type KeyValue interface {
	// Get retrieves the value for a key.
	Get(key string) ([]byte, error)
	// Set sets the value for a key.
	Set(key string, value []byte) error
	// Delete removes a key
	Delete(key string) error
	// ForEach executes a function for each key/value pair
	ForEach(fn func(k string, v []byte) error) error
}

type NotFound

type NotFound struct {
	Entity string
}

func (NotFound) Error

func (e NotFound) Error() string

type Storage

type Storage interface {
	// CreateBucket creates a new bucket with the given name and returns it.
	CreateBucket(name string) (Bucket, error)
	// CreateBucketIfNotExists creates a new bucket if it doesn't already exist and returns it.
	CreateBucketIfNotExists(name string) (Bucket, error)
	// Bucket returns a bucket by name.
	Bucket(name string) (Bucket, error)
	// DeleteBucket deletes a bucket with the given name.
	DeleteBucket(name string) error
}

Jump to

Keyboard shortcuts

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