kvstore

package
v0.0.0-...-b42ad41 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2020 License: MIT Imports: 8 Imported by: 0

README

go-utils/kvstore

This provides an on-disk key/value store. It uses BoltDB under the hood and just wraps some common operations.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Database

type Database interface {
	// Load loads the data from the DB with the specified key.
	Load(key string) ([]byte, error)

	// Save puts bytes in the bucket. For a new item, set key to the empty
	// string if you want a key automatically chosen for you. Returns the key
	// used for saving data and any error that occurred.
	Save(key string, value []byte) (string, error)

	// HasKey returns true if the key is in the DB, false if not
	HasKey(key string) bool

	// Delete deletes a key from the database
	Delete(key string) error

	// List returns all keys
	List() ([]string, error)

	// Close disconnects from the database and cleans up
	Close() error
}

Database defines an interface for a database utility

func OpenDB

func OpenDB(name string) (Database, error)

OpenDB opens a Database connection. `name` may be an absolute path or a directory name relative to the user XDG data directory

Jump to

Keyboard shortcuts

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