Documentation ¶
Index ¶
- type DB
- func (db *DB) Batch(fn func(*bolt.Tx) error) error
- func (db *DB) Close() error
- func (db *DB) KeyBatch(f func(*Tx) bool)
- func (db *DB) KeyCAS(key string, old_digest, new_digest c4.Digest) bool
- func (db *DB) KeyDelete(key string) (c4.Digest, error)
- func (db *DB) KeyDeleteAll(key_prefixs ...string) (int, error)
- func (db *DB) KeyFind(digest c4.Digest) []string
- func (db *DB) KeyGet(key string) (c4.Digest, error)
- func (db *DB) KeyGetAll(key_prefix ...string) <-chan Entry
- func (db *DB) KeySet(key string, digest c4.Digest) (c4.Digest, error)
- func (db *DB) LinkDelete(relationship string, source c4.Digest, targets ...c4.Digest) (int, error)
- func (db *DB) LinkDeleteAll(sources ...c4.Digest) (int, error)
- func (db *DB) LinkGet(relationship string, source c4.Digest) <-chan Entry
- func (db *DB) LinkGetAll(sources ...c4.Digest) <-chan Entry
- func (db *DB) LinkSet(relationship string, source c4.Digest, targets ...c4.Digest) error
- func (db *DB) Stats() *Stats
- func (db *DB) TreeDelete(tree c4.Digest) error
- func (db *DB) TreeGet(tree_digest c4.Digest) (*c4.Tree, error)
- func (db *DB) TreeSet(tree *c4.Tree) error
- func (db *DB) Update(fn func(*bolt.Tx) error) error
- func (db *DB) View(fn func(*bolt.Tx) error) error
- type Entry
- type Options
- type Stats
- type TreeStrategyType
- type Tx
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB stores
func Open ¶
Open opens or initializes a DB for the given path. When creating file permissions are set to 0700, when opening an existing database file permissions are not modified.
func (*DB) Batch ¶
Update, View and Batch call the methods of the same name on the underlying bolt database. See github.com/boltdb/bolt for more information.
Batch calls fn as part of a batch. It behaves similar to Update, except:
1. concurrent Batch calls can be combined into a single Bolt transaction.
2. the function passed to Batch may be called multiple times, regardless of whether it returns error or not.
This means that Batch function side effects must be idempotent and take permanent effect only after a successful return is seen in caller.
The maximum batch size and delay can be adjusted with DB.MaxBatchSize and DB.MaxBatchDelay, respectively.
Batch is only useful when there are multiple goroutines calling it.
func (*DB) KeyCAS ¶
KeyCAS implements a 'compare and swap' operation on key. In other words if the value of key is not the expected `old_digest` value the operation will do noting and return false. If `old_digest` is the current value of key the key is updated with new_digest, KeyCAS returns `true`.
func (*DB) KeyDeleteAll ¶
KeyDeleteAll deletes all keys with the provided prefix, or all keys in the case of an empty string. KeyDeleteAll returns the number of items deleted and/or an error.
func (*DB) KeySet ¶
KeySet stores a digest with the key provided. If the key was previously set the previous digest is returned otherwise nil is returned.
func (*DB) LinkDelete ¶
func (*DB) LinkSet ¶
LinkSet creates a relationship between a `source` digest and one or more `target` digests. The relationship is an arbitrary string that is application dependent, but could be something like "metadata", "parent", or "children" for example.
func (*DB) Update ¶
Update, View and Batch call the methods of the same name on the underlying bolt database. See github.com/boltdb/bolt for more information.
Update executes a function within the context of a read-write managed transaction. If no error is returned from the function then the transaction is committed. If an error is returned then the entire transaction is rolled back. Any error that is returned from the function or returned from the commit is returned from the Update() method.
Attempting to manually commit or rollback within the function will cause a panic.
func (*DB) View ¶
Update, View and Batch call the methods of the same name on the underlying bolt database. See github.com/boltdb/bolt for more information.
View executes a function within the context of a managed read-only transaction. Any error that is returned from the function is returned from the View() method.
Attempting to manually rollback within the function will cause a panic.
type Entry ¶
type Entry interface { Key() string Value() c4.Digest Source() c4.Digest Target() c4.Digest Relationships() []string Err() error Stop() Close() }
Entry is an interface for items returned from listing methods like KeyGetAll. For performance an Entry must be closed when done using it.
type Options ¶
type Options struct { // Maximum size in bytes of a tree stored directly in the database. Trees // over this size will be written out to separate files. TreeMaxSize int // Sets the strategy to use for tree storage. TreeStrategy TreeStrategyType // Path to an alternative storage location. ExternalStore []string }
type TreeStrategyType ¶
type TreeStrategyType int
func init() { bucketList := [][]byte{keyBucket, linkBucket} }
const ( TreeStrategyNone TreeStrategyType = iota // Sets the tree storage strategy to always store the entire tree. TreeStrategyCache // Sets the tree storage strategy to always store only the id list, and // compute the tree when restored. TreeStrategyCompute // Sets the tree storage strategy to automatically balance between the // cashing strategy and computing strategy. TreeStrategyBalance )