Documentation ¶
Overview ¶
wrapper for Bolt database
Index ¶
- Variables
- type BasicKey
- type Byte
- type ContainedKey
- type DB
- func (b *DB) Batch(f func(tx *bolt.Tx) error) error
- func (b *DB) Close()
- func (b *DB) Delete(tx *bolt.Tx, item Item) error
- func (b *DB) EnableTransactionDebug()
- func (b *DB) Exists(tx *bolt.Tx, key []byte, item Item) bool
- func (b *DB) ForEach(tx *bolt.Tx, item Item, handler func(cursor *bolt.Cursor) (bool, error)) error
- func (b *DB) ForEachReverse(tx *bolt.Tx, item Item, handler func(cursor *bolt.Cursor) (bool, error)) error
- func (b *DB) Get(tx *bolt.Tx, key []byte, item Item) error
- func (b *DB) Purger(itemtype Item, interval time.Duration, notifyQuit, notifyPurge *topic.Topic)
- func (b *DB) Put(tx *bolt.Tx, item Item) error
- func (b *DB) Update(f func(tx *bolt.Tx) error) error
- func (b *DB) UpdateMeta(tx *bolt.Tx, olditem *Meta, newitem *Meta) error
- func (b *DB) View(f func(tx *bolt.Tx) error) error
- type Flag
- type Item
- type Meta
- func (m *Meta) Bytes() ([]byte, error)
- func (m *Meta) DeserializeFrom(d []byte) error
- func (m *Meta) GetItem(item Item) error
- func (m *Meta) GetTransfer() *MetaTransfer
- func (m *Meta) InvalidateIn(in time.Duration)
- func (m *Meta) IsValid() bool
- func (m *Meta) Key() []byte
- func (m *Meta) SetKey(key []byte)
- func (m *Meta) StoreID() []byte
- type MetaTransfer
- type NotifyPurge
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = errors.New("Item not found")
var Never = time.Time{}
time value to check for "unset" metadata time
Functions ¶
This section is empty.
Types ¶
type BasicKey ¶
type BasicKey struct {
KeyData []byte
}
Use this to wrap items that do not generate a key from their own data. Note that upon creating new items, you must call SetKey() to set up the key value.
type Byte ¶
Use this to wrap pure binary data items. These will have to embed this struct and define their own methods StoreID and Key.
func (*Byte) DeserializeFrom ¶
passthrough deserialization
type ContainedKey ¶
type ContainedKey struct{}
A no-op wrapper for items that generate/contain their own key
func (*ContainedKey) SetKey ¶
func (c *ContainedKey) SetKey(key []byte)
no operation for the SetKey method
type DB ¶
Wrapper for a single Bolt database
func (*DB) EnableTransactionDebug ¶
func (b *DB) EnableTransactionDebug()
enable a debugger for bolt database transactions
func (*DB) Exists ¶
test for the existence of an item, identified by key The item parameter must be a pointer to an item of the kind to be tested for.
func (*DB) ForEach ¶
iterate through the items in a bucket Calls a callback function handler, which will get the key and the cursor as parameters so it can do deleten. The actual item is stored to the item parameter - must be a pointer. When the callback handler returns true, that will trigger a reset of the loop, starting anew. Do this after a delete.
func (*DB) ForEachReverse ¶
func (b *DB) ForEachReverse(tx *bolt.Tx, item Item, handler func(cursor *bolt.Cursor) (bool, error)) error
like ForEach, but running from last item to first one
func (*DB) Get ¶
get an item, identified by key. The item parameter must be a pointer to the value that will get set.
func (*DB) Purger ¶
Run a background task to purge invalid items of a given type in given intervals. Pass a *topic.Topic to be able to receive NotifyPurge messages for each purged item.
func (*DB) UpdateMeta ¶
update a record that is encapsuled in a Meta struct
type Flag ¶
type Flag struct{ BasicKey }
You can use this to implement simple Flag items. These will have to embed this struct and define their own method StoreID.
type Item ¶
type Item interface { // return a key for the data item Key() []byte // return a store id for the data item StoreID() []byte // serialize data item Bytes() ([]byte, error) // unserialize data item DeserializeFrom([]byte) error // set key when reading SetKey([]byte) }
For convenient storage, special methods are provided that apply to data which fulfills the Item interface
type Meta ¶
type Meta struct { // first creation of an item with this key in this store Created time.Time // last update of the item with this key in this store Updated time.Time // date when this item becomes invalid and may be purged Invalid time.Time // contains filtered or unexported fields }
Database entry metadata
func (*Meta) DeserializeFrom ¶
fast Meta binary decoder
func (*Meta) GetTransfer ¶
func (m *Meta) GetTransfer() *MetaTransfer
Get exportable metadata/data struct
func (*Meta) InvalidateIn ¶
Set invalidation date via duration
type MetaTransfer ¶
For data import/export, we need to make the content accessible.