kv

package
v1.2.3 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2025 License: MIT Imports: 12 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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) IsStopped

func (db *DB) IsStopped() bool

IsStopped returns true if db is already stopped

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