state

package
v0.0.0-...-ee4beea Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2020 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("ErrorNotFound")

ErrNotFound is returned when no results are returned from the database

Functions

This section is empty.

Types

type DBStore

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

DBStore uses LevelDB to store values.

func NewDBStore

func NewDBStore(path string) (s *DBStore, err error)

NewDBStore creates a new instance of DBStore.

func NewInmemoryStore

func NewInmemoryStore() *DBStore

NewInmemoryStore returns a new instance of DBStore. To be used only in tests and simulations.

func (*DBStore) Close

func (s *DBStore) Close() error

Close releases the resources used by the underlying LevelDB.

func (*DBStore) Delete

func (s *DBStore) Delete(key string) (err error)

Delete removes entries stored under a specific key.

func (*DBStore) Get

func (s *DBStore) Get(key string, i interface{}) (err error)

Get retrieves a persisted value for a specific key. If there is no results ErrNotFound is returned. The provided parameter should be either a byte slice or a struct that implements the encoding.BinaryUnmarshaler interface

func (*DBStore) Put

func (s *DBStore) Put(key string, i interface{}) (err error)

Put stores an object that implements Binary for a specific key.

type Store

type Store interface {
	Get(key string, i interface{}) (err error)
	Put(key string, i interface{}) (err error)
	Delete(key string) (err error)
	Close() error
}

Store defines methods required to get, set, delete values for different keys and close the underlying resources.

Jump to

Keyboard shortcuts

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