kv

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: May 12, 2023 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Db

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

Db is a generic key-value database that supports transactions and buckets. Keys and bucket names are strings. Values are byte arrays. This struct is an adapter for bolt.

func Open

func Open(path string) (db *Db, err error)

Open opens a database, creating it if it doesn't exist.

func (*Db) Begin

func (db *Db) Begin(writable bool) (tx *Tx, err error)

Begin starts a tansaction

func (*Db) Close

func (db *Db) Close() (err error)

Close closes the db.

type Tx

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

Tx is a generic transaction. This struct is an adapter for bolt.

func (*Tx) Commit

func (tx *Tx) Commit() (err error)

Commit commits a transaction

func (*Tx) Delete

func (tx *Tx) Delete(bucket string, key string) (err error)

Delete removes a record from the given bucket.

func (*Tx) Get

func (tx *Tx) Get(bucket string, key string) (value []byte, err error)

Get retrieves a record from the given bucket. Returns a nil value if the key or bucket does not exist or if the key is a nested bucket.

func (*Tx) List

func (tx *Tx) List(bucket string) (keys chan string, err error)

List generates a list of all keys in the given bucket.

func (*Tx) MakeBucket

func (tx *Tx) MakeBucket(bucket string) (b *bolt.Bucket, err error)

MakeBucket creates a new bucket.

func (*Tx) Put

func (tx *Tx) Put(bucket string, key string, value []byte) (err error)

Put adds or replaces a record in the given bucket.

func (*Tx) Rollback

func (tx *Tx) Rollback() (err error)

Rollback rolls back a transaction

Jump to

Keyboard shortcuts

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