mirror of
https://github.com/rclone/rclone.git
synced 2024-12-23 15:38:57 +01:00
50df8cec9c
Add bolt-based key-value database support. Quick API description: https://github.com/rclone/rclone/pull/5587#issuecomment-942174768
36 lines
716 B
Go
36 lines
716 B
Go
package kv
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/pkg/errors"
|
|
)
|
|
|
|
// package errors
|
|
var (
|
|
ErrEmpty = errors.New("database empty")
|
|
ErrInactive = errors.New("database stopped")
|
|
ErrUnsupported = errors.New("unsupported on this OS")
|
|
)
|
|
|
|
// Op represents a database operation
|
|
type Op interface {
|
|
Do(context.Context, Bucket) error
|
|
}
|
|
|
|
// Bucket decouples bbolt.Bucket from key-val operations
|
|
type Bucket interface {
|
|
Get([]byte) []byte
|
|
Put([]byte, []byte) error
|
|
Delete([]byte) error
|
|
ForEach(func(bkey, data []byte) error) error
|
|
Cursor() Cursor
|
|
}
|
|
|
|
// Cursor decouples bbolt.Cursor from key-val operations
|
|
type Cursor interface {
|
|
First() ([]byte, []byte)
|
|
Next() ([]byte, []byte)
|
|
Seek([]byte) ([]byte, []byte)
|
|
}
|