Documentation ¶
Overview ¶
package db implements Bolt based database which can be encrypted on the fly and which supports automatic backups. It offers very simple API and hides all the complex stuff behind it. It's thread safe. More information see the Cfg struct.
Index ¶
- func AddKeyValueToBucket(bucket []byte, keyValue, index *Data) (err error)
- func Backup() (did bool, err error)
- func BackupTicker(interval time.Duration) (done chan<- struct{})
- func Close() (err error)
- func GetKeyValueFromBucket(bucket []byte, index, keyValue *Data) (found bool, err error)
- func Init(cfg Cfg) (err error)
- func RmKeyValueFromBucket(bucket []byte, index *Data) (err error)
- func Wipe() (err error)
- type Cfg
- type Data
- type Filter
- type Mgd
- func (db *Mgd) AddKeyValueToBucket(bucket []byte, keyValue, index *Data) (err error)
- func (db *Mgd) Backup() (did bool, err error)
- func (db *Mgd) BackupTicker(interval time.Duration) (done chan<- struct{})
- func (db *Mgd) Close() (err error)
- func (db *Mgd) GetKeyValueFromBucket(bucket []byte, index, keyValue *Data) (found bool, err error)
- func (db *Mgd) RmKeyValueFromBucket(bucket []byte, index *Data) (err error)
- func (db *Mgd) Wipe() (err error)
- type Use
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddKeyValueToBucket ¶
AddKeyValueToBucket add value to bucket pointed by the index. keyValue and index use Data type's operators to encrypt and hash data on the fly.
func Backup ¶
Backup takes backup copy of the database. Before backup the database is closed automatically and only dirty databases are backed up.
func BackupTicker ¶
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 ¶
GetKeyValueFromBucket writes keyValue data by the index from a bucket. It returns `found` if key value exists. Errors will return only if it cannot perform the transaction successfully.
func Init ¶
Init initializes managed version of the encrypted database. Database is ready to use after this call. See more information of Cfg struct.
func RmKeyValueFromBucket ¶ added in v0.1.21
RmKeyValueFromBucket removes value pointed by the index from the bucket. The index uses Data type's operators to encrypt and hash data on the fly.
Types ¶
type Cfg ¶
type Cfg struct { Filename string // Filename is full path file name of the DB file BackupName string // Base part of the backup file names. Date and time is added. Buckets [][]byte // Buckets is list of the buckets needed }
Cfg is configuration needed to create and open managed database.
type Data ¶
Data is general data element for encrypted database. It offers placeholders for read, write, and use operators to over write.
type Mgd ¶
type Mgd struct { Cfg // contains filtered or unexported fields }
Mgd is a managed and encrypted (option, can be pre-procession as well) DB.
func New ¶ added in v0.1.21
New creates a new managed and encrypted database. This is a preferred way to use the managed database package. There is also the alternated Init function when you don't need to store the Mgd instance by yourself. It's for the cases when only one managed database is needed per a process or an application. Database is ready to use after this call. You don't need to open it and backup can be taken during the run. See more information of Cfg struct.
func (*Mgd) AddKeyValueToBucket ¶ added in v0.1.21
AddKeyValueToBucket add value to bucket pointed by the index. keyValue and index use Data type's operators to encrypt and hash data on the fly.
func (*Mgd) Backup ¶ added in v0.1.21
Backup takes backup copy of the database. Before backup the database is closed automatically and only dirty databases are backed up.
func (*Mgd) BackupTicker ¶ added in v0.1.21
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 (*Mgd) Close ¶ added in v0.1.21
Close closes the database. It can be used after that if wanted. Transactions opens the database when needed.
func (*Mgd) GetKeyValueFromBucket ¶ added in v0.1.21
func (db *Mgd) 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. Errors will return only if it cannot perform the transaction successfully.
func (*Mgd) RmKeyValueFromBucket ¶ added in v0.1.21
RmKeyValueFromBucket removes value pointed by the index from the bucket. The index uses Data type's operators to encrypt and hash data on the fly.