kv

package
v1.66.5 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package kv provides key/value database.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEmpty       = errors.New("database empty")
	ErrInactive    = errors.New("database stopped")
	ErrUnsupported = errors.New("unsupported on this OS")
)

package errors

Functions

func Exit

func Exit()

Exit immediately stops all databases

func Supported

func Supported() bool

Supported returns true on supported OSes

Types

type Bucket

type Bucket interface {
	Get([]byte) []byte
	Put([]byte, []byte) error
	Delete([]byte) error
	ForEach(func(bkey, data []byte) error) error
	Cursor() Cursor
}

Bucket decouples bbolt.Bucket from key-val operations

type Cursor

type Cursor interface {
	First() ([]byte, []byte)
	Next() ([]byte, []byte)
	Seek([]byte) ([]byte, []byte)
}

Cursor decouples bbolt.Cursor from key-val operations

type DB

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

DB represents a key-value database

func Get

func Get(facility string, f fs.Fs) *DB

Get returns database record for given filesystem and facility

func Start

func Start(ctx context.Context, facility string, f fs.Fs) (*DB, error)

Start a new key-value database

func (*DB) Do

func (db *DB) Do(write bool, op Op) error

Do a key-value operation and return error when done

func (*DB) Path

func (db *DB) Path() string

Path returns database path

func (*DB) Stop

func (db *DB) Stop(remove bool) error

Stop a database loop, optionally removing the file

type Op

type Op interface {
	Do(context.Context, Bucket) error
}

Op represents a database operation

Jump to

Keyboard shortcuts

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