db

package
v0.0.0-...-199710d Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package db implements high-level database driver (multiple badger "buckets").

Index

Constants

View Source
const DefaultBucketName = "default"

DefaultBucketName contains the name of bucket created on database initialization.

Variables

This section is empty.

Functions

func InitDatabase

func InitDatabase(datadir string, bucketName string) error

InitDatabase creates the local database for use.

Types

type Bucket

type Bucket struct {
	Name string
	// contains filtered or unexported fields
}

Bucket is the single "table" within the database.

func (*Bucket) Close

func (b *Bucket) Close() error

Close the underlying BadgerDB.

func (*Bucket) Delete

func (b *Bucket) Delete(key string) error

Delete value stored under key.

func (*Bucket) Get

func (b *Bucket) Get(key string) ([]byte, error)

Get value stored under key.

func (*Bucket) List

func (b *Bucket) List(prefix string) ([]string, error)

List keys with given prefix.

func (*Bucket) Set

func (b *Bucket) Set(key string, value []byte) error

Set key to point to value.

type Database

type Database struct {
	DefaultBucket string
	// contains filtered or unexported fields
}

Database is the implementation of local storage layer.

func OpenDatabase

func OpenDatabase(datadir string) (*Database, error)

OpenDatabase opens the local database for use.

func (*Database) Close

func (db *Database) Close() error

Close the database.

func (*Database) Count

func (db *Database) Count() int

Count all available buckets.

func (*Database) Create

func (db *Database) Create(name string) error

Create creates a new database/bucket with given name.

func (*Database) Drop

func (db *Database) Drop(name string) error

Drop given bucket.

func (*Database) Get

func (db *Database) Get(name string) (*Bucket, error)

Get bucket with given name, or error if it doesn't exist.

func (*Database) List

func (db *Database) List(prefix string) []string

List all available buckets (names only).

Jump to

Keyboard shortcuts

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