store

package
v1.15.2 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2019 License: MIT Imports: 7 Imported by: 2

Documentation

Overview

Package store provides a simple and convenient data store interface for plugins to persist data along with a default filed-based leveldb implementation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BytesStorer

type BytesStorer interface {
	io.Closer
	Scanner

	Get(key []byte) (value []byte, err error)
	Put(key []byte, value []byte) (err error)
	Delete(key []byte) (err error)
}

BytesStorer is implemented by any value that has the Get/Put/Delete/Scan and Closer methods on byte arrays for keys/values.

type LevelDB

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

LevelDB holds a datastore name and its leveldb instance

func NewLevelDB

func NewLevelDB(name string, storagePath string) (ldb *LevelDB, err error)

NewLevelDB instantiates and open a new LevelDB instance backed by a leveldb database. If the leveldb database doesn't exist, one is created

func (*LevelDB) Close

func (ldb *LevelDB) Close() (err error)

Close closes the LevelDB

func (*LevelDB) Delete

func (ldb *LevelDB) Delete(key []byte) (err error)

Delete deletes an entry for a given key

func (*LevelDB) DeleteString

func (ldb *LevelDB) DeleteString(key string) (err error)

DeleteString deletes an entry for a given key string

func (*LevelDB) Get

func (ldb *LevelDB) Get(key []byte) (value []byte, err error)

Get retrieves a value associated to the key

func (*LevelDB) GetString

func (ldb *LevelDB) GetString(key string) (value string, err error)

GetString retrieves a value associated to the key

func (*LevelDB) Put

func (ldb *LevelDB) Put(key []byte, value []byte) (err error)

Put adds or updates a value associated to the key

func (*LevelDB) PutString

func (ldb *LevelDB) PutString(key string, value string) (err error)

PutString adds or updates a value associated to the key

func (*LevelDB) Scan

func (ldb *LevelDB) Scan() (entries map[string]string, err error)

Scan returns the complete set of key/values from the database

type Scanner

type Scanner interface {
	Scan() (entries map[string]string, err error)
}

Scanner is implemented by any value that has the Scan method returning all key/values as strings.

Since []byte aren't allowed as map keys, we use don't have an equivalent Scanner interface returning the data as bytes. For implementers, it should be easy to convert the []byte values to string with a simple string(value) conversion as strings are immutable arrays of bytes

type StringStorer

type StringStorer interface {
	io.Closer
	Scanner

	GetString(key string) (value string, err error)
	PutString(key string, value string) (err error)
	DeleteString(key string) (err error)
}

StringStorer is implemented by any value that has the Get/Put/Delete/Scan and Closer methods on string keys/values.

Directories

Path Synopsis
Package datastoredb provides an implementation of github.com/alexandre-normand/slackscot/store's StringStorer interface backed by the Google Cloud Datastore.
Package datastoredb provides an implementation of github.com/alexandre-normand/slackscot/store's StringStorer interface backed by the Google Cloud Datastore.
Package inmemorydb provides an implementation of github.com/alexandre-normand/slackscot/store's StringStorer interface as an in-memory data store relying on a wrapping StringStorer for actual persistence.
Package inmemorydb provides an implementation of github.com/alexandre-normand/slackscot/store's StringStorer interface as an in-memory data store relying on a wrapping StringStorer for actual persistence.

Jump to

Keyboard shortcuts

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