boltdb

package
v6.3.3-rc1+incompatible Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2019 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 4 more Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BoltDB

type BoltDB struct {
	Sem sync.RWMutex
	// contains filtered or unexported fields
}

This database stores and retrieves interfaces.IBlock instances. To do that, it needs a list of buckets that the using function wants, so it can make sure all those buckets exist. (Avoids checking and building buckets in every write).

It also needs a map of a hash to a interfaces.IBlock instance. To support this, every block needs to be able to give the database a Hash for its type. This has to match the reverse, where looking up the hash gives the database the type for the hash. This way, the database can marshal and unmarshal interfaces.IBlocks for storage in the database. And since the interfaces.IBlocks can provide the hash, we don't need two maps. Just the Hash to the interfaces.IBlock.

Lastly it needs a filename with a full path. If none is specified, it will use "/tmp/bolt_my.db". Not the best idea to let this code default.

func NewAndCreateBoltDB

func NewAndCreateBoltDB(bucketList [][]byte, filename string) *BoltDB

func NewBoltDB

func NewBoltDB(bucketList [][]byte, filename string) *BoltDB

func (*BoltDB) Clear

func (db *BoltDB) Clear(bucket []byte) error

func (*BoltDB) Close

func (db *BoltDB) Close() error

func (*BoltDB) Delete

func (db *BoltDB) Delete(bucket []byte, key []byte) error

We don't care if delete works or not. If the key isn't there, that's ok

func (*BoltDB) DoesKeyExist

func (db *BoltDB) DoesKeyExist(bucket, key []byte) (bool, error)

func (*BoltDB) Get

func (db *BoltDB) Get(bucket []byte, key []byte, destination interfaces.BinaryMarshallable) (interfaces.BinaryMarshallable, error)

func (*BoltDB) GetAll

func (*BoltDB) Init

func (db *BoltDB) Init(bucketList [][]byte, filename string)

We have to make accommodation for many Init functions. But what we really want here is:

Init(bucketList [][]byte, filename string)

func (*BoltDB) ListAllBuckets

func (db *BoltDB) ListAllBuckets() ([][]byte, error)

func (*BoltDB) ListAllKeys

func (db *BoltDB) ListAllKeys(bucket []byte) (keys [][]byte, err error)

func (*BoltDB) Put

func (db *BoltDB) Put(bucket []byte, key []byte, data interfaces.BinaryMarshallable) error

func (*BoltDB) PutInBatch

func (db *BoltDB) PutInBatch(records []interfaces.Record) error

func (*BoltDB) Trim

func (db *BoltDB) Trim()

Can't trim a real database

Jump to

Keyboard shortcuts

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