byteStore

package module
v0.0.0-...-b783d3c Latest Latest
Warning

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

Go to latest
Published: May 12, 2017 License: MIT Imports: 2 Imported by: 0

README

Go Report Card GoDoc

byteStore

An abstraction library to enable simple Get, Put and other operations on top of the fantastic BoltDB key value store. Import the library and get a new ByteStore with the byteStore.New() function to get started.

byteStore.New(dbFileName string) (ByteStore, error)

The user can simply use the ByteStore object's methods and not worry about database complexities. All methods are thread safe, backed by BoltDB's transactional nature, so use indiscriminately throughout your Goroutines!

(ByteStore) Get(bucket string, key string) []byte

(ByteStore) GetBucket(bucket string) []KeyValue

(ByteStore) GetBucketValues(bucket string) [][]byte

(ByteStore) Put(bucket string, key string, value []byte) error

(ByteStore) Delete(bucket string, key string) error

(ByteStore) DeleteBucket(bucket string) error

(ByteStore) Close() error

The ByteStore type also exposes the underlying BoltDB driver publicly (ByteStore.BoltDB), meaning that if you want to do any more complex transactions not offered by the ByteStore methods, you can use boltDB directly. I hope you enjoy the library, pull and feature requests are welcome.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ByteStore

type ByteStore struct {
	BoltDB *bolt.DB
}

ByteStore is the struct which contains the pulicly exposed *bolt.DB driver and attached byteStore methods

func New

func New(dbFileName string) (ByteStore, error)

New returns an initialised byteStore with the dbFileName initialised at the dbFileName target location

func (ByteStore) Close

func (bs ByteStore) Close() error

Close safely closes the database.

func (ByteStore) Delete

func (bs ByteStore) Delete(bucket string, key string) error

Delete removes the key/value pair, returns nil if key/value doesn't exist

func (ByteStore) DeleteBucket

func (bs ByteStore) DeleteBucket(bucket string) error

DeleteBucket deletes a whole bucket

func (ByteStore) Get

func (bs ByteStore) Get(bucket string, key string) []byte

Get retrieves the value using the bucket and key provided, an empty byte will be returned if no value is present.

func (ByteStore) GetBucket

func (bs ByteStore) GetBucket(bucket string) []KeyValue

GetBucket retrieves all keys and values in a bucket, an empty KeyValue slice will be returned if no values are present.

func (ByteStore) GetBucketValues

func (bs ByteStore) GetBucketValues(bucket string) [][]byte

GetBucketValues retrieves all values in a bucket, an empty slice of bytes will be returned if no values are present.

func (ByteStore) Put

func (bs ByteStore) Put(bucket string, key string, value []byte) error

Put inserts the key value into the db in the bucket specified.

type KeyValue

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

KeyValue is a container for a key value pair, most usually used for holding a slice of key value pairs

Jump to

Keyboard shortcuts

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