db

package
v0.1.10 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2021 License: Apache-2.0 Imports: 7 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddKeyValueToBucket

func AddKeyValueToBucket(bucket []byte, keyValue, index *Data) (err error)

AddKeyValueToBucket add value to bucket pointed by the index. keyValue and index use Data types operators to encrypt and hash data on the fly.

func Backup

func Backup() (did bool, err error)

Backup takes backup copy of the database. Before backup the database is closed.

func BackupTicker

func BackupTicker(interval time.Duration) (done chan<- struct{})

BackupTicker creates a backup ticker which takes backup copy of the database file specified by the interval. Ticker can be stopped with returned done channel.

func Close

func Close() (err error)

Close closes the database. It can be used after that if wanted. Transactions opens the database when needed.

func GetKeyValueFromBucket

func GetKeyValueFromBucket(bucket []byte, index, keyValue *Data) (found bool, err error)

GetKeyValueFromBucket writes keyValue data by the index from a bucket. It returns found if key value exists. Returns are only if it cannot perform the transaction successfully.

func Init

func Init(cfg Cfg) (err error)

Init initializes managed version of the encrypted database. Database is ready to use after this call. See more information of Cfg struct.

func Wipe

func Wipe() (err error)

Wipe removes the whole database and its master file.

Types

type Cfg

type Cfg struct {
	Filename   string
	BackupName string
	Buckets    [][]byte
}

type Data

type Data struct {
	Data  []byte
	Read  Filter
	Write Filter
	Use
	Result interface{}
}

Data is general data element for encrypted database. It offers placeholders for read, write, and use operators to over write.

type Filter

type Filter func(value []byte) (k []byte)

type Mgd

type Mgd struct {
	Cfg
	// contains filtered or unexported fields
}

type Use

type Use func(value []byte) interface{}

Jump to

Keyboard shortcuts

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