Documentation
¶
Index ¶
- Variables
- type BoltKeyspace
- func (b *BoltKeyspace) Contains(key string) (exists bool, err error)
- func (b *BoltKeyspace) Delete(key string) error
- func (b *BoltKeyspace) ForEach(each ItemHandler) error
- func (b *BoltKeyspace) Get(key string) (value []byte, err error)
- func (b *BoltKeyspace) GetName() string
- func (b *BoltKeyspace) Insert(key string, value []byte) error
- func (b *BoltKeyspace) List(keys []string, callback func(k, v []byte)) error
- func (b *BoltKeyspace) ReadTx(callback func(*bolt.Bucket)) error
- func (b *BoltKeyspace) Size() (value int64)
- func (b *BoltKeyspace) Update(key string, value []byte) error
- func (b *BoltKeyspace) WriteTx(callback func(*bolt.Bucket)) error
- type DB
- type ItemHandler
- type KeyValueDatabase
- type Keyspace
Constants ¶
This section is empty.
Variables ¶
var ( // ErrKeyNotFound is returned if a Keyspace did not contain the key ErrKeyNotFound = errors.New("Key does not exist") // ErrEmptyKeyList is returned if Keyspace.List() is called with no keys ErrEmptyKeyList = errors.New("Empty key list") )
Functions ¶
This section is empty.
Types ¶
type BoltKeyspace ¶
type BoltKeyspace struct {
// contains filtered or unexported fields
}
BoltKeyspace implements the Keyspace interface on top of a boltdb connection
func (*BoltKeyspace) Contains ¶
func (b *BoltKeyspace) Contains(key string) (exists bool, err error)
Contains determines if a key already exists in the keyspace
func (*BoltKeyspace) Delete ¶
func (b *BoltKeyspace) Delete(key string) error
Delete removes a key from the keyspace
func (*BoltKeyspace) ForEach ¶
func (b *BoltKeyspace) ForEach(each ItemHandler) error
ForEach iterates over all the key value pairs in the keyspace
func (*BoltKeyspace) Get ¶
func (b *BoltKeyspace) Get(key string) (value []byte, err error)
Get returns the value for the given key
func (*BoltKeyspace) GetName ¶
func (b *BoltKeyspace) GetName() string
GetName returns the name of the keyspace
func (*BoltKeyspace) Insert ¶
func (b *BoltKeyspace) Insert(key string, value []byte) error
Insert adds a key value pair to the databaes
func (*BoltKeyspace) List ¶
func (b *BoltKeyspace) List(keys []string, callback func(k, v []byte)) error
List iterates over the given keys and calls the ItemHandler with each key value pair
func (*BoltKeyspace) ReadTx ¶
func (b *BoltKeyspace) ReadTx(callback func(*bolt.Bucket)) error
ReadTx allows for more complex read operations on the keyspace
func (*BoltKeyspace) Size ¶
func (b *BoltKeyspace) Size() (value int64)
Size returns the number of keys in the keyspace
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB wraps a BoltDB connection
func (*DB) DeleteKeyspace ¶
DeleteKeyspace removes a keyspace from the database
type ItemHandler ¶
ItemHandler represents a callback for processing a single key-value pair.
type KeyValueDatabase ¶
type KeyValueDatabase interface {
// GetOrCreatKeyspace returns a new keyspace instance from the database, creating it if it doesn't exist
GetOrCreateKeyspace(string) (Keyspace, error)
// DeleteKeyspace removes a keyspace from the database
DeleteKeyspace(string) error
// Close closes the database connection
Close() error
}
KeyValueDatabase is used as an interface for accessing multiple keyspaces.
func NewLeaf ¶
func NewLeaf(file string) (KeyValueDatabase, error)
NewLeaf creates a connection to a BoltDB file
type Keyspace ¶
type Keyspace interface {
// GetName returns the name of the keyspace
GetName() string
// List finds all the keys listed and calls the function provided with the key value pairs
List([]string, func(k, v []byte)) error
// Insert adds a key value to the keyspace
Insert(string, []byte) error
// Get returns a value with the associated key and returns an error if the key does not exist
Get(string) ([]byte, error)
// Update overrides the existing value associated with the given key
Update(string, []byte) error
// Delete removes a key from the keyspace
Delete(string) error
// Size returns the number of items in the keyspace
Size() int64
// ForEach iterates over all the keys in the keyspace
ForEach(ItemHandler) error
// Contains determines if the given key exists in the keyspace
Contains(string) (bool, error)
// ReadTx allows for more complicated read operations on a particular key, such as reading nested values.
ReadTx(func(*bolt.Bucket)) error
// WriteTx allows for more complicated write operations on a particular key, such as writing nested values.
WriteTx(func(*bolt.Bucket)) error
}
Keyspace is an interface for Database keyspaces. It is used as a wrapper for database actions.