storage

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2021 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backend

type Backend interface {
	Get(key string) (string, error)
	Put(key, value string) error
}

Backend wraps the two basic methods to interact with a key-value store.

type BadgerBackend

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

BadgerBackend is a backend implemented using BadgerDB.

func NewBadgerBackend

func NewBadgerBackend(path string) (*BadgerBackend, error)

NewBadgerBackend returns an initialized backend, opening (or creating, if not present) a badgerDB from the specified path.

func (*BadgerBackend) Close

func (b *BadgerBackend) Close() error

Close closes the underlying badgerDB.

func (*BadgerBackend) Get

func (b *BadgerBackend) Get(key string) (string, error)

Get takes a key as a string and returns the associated value saved in the storage, if present. If something goes wrong, it returns a non-nil error.

func (*BadgerBackend) Put

func (b *BadgerBackend) Put(key, value string) error

Put takes a key-value pair in input and saves them in the underlying storage. It returns an error if something goes wrong.

Jump to

Keyboard shortcuts

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