diff options
author | Ben Johnson <benbjohnson@yahoo.com> | 2015-10-21 09:30:33 -0600 |
---|---|---|
committer | Ben Johnson <benbjohnson@yahoo.com> | 2015-10-21 09:30:33 -0600 |
commit | 12af751e869acdcc32325a8628b87f0405f9cee9 (patch) | |
tree | c2ad79574a3bac06e020a89acbbb0cde1a2cf78d | |
parent | Merge pull request #442 from pmezard/mention-address-space-consumption (diff) | |
parent | bucket: document buckets are valid only during the transaction (diff) | |
download | dedo-12af751e869acdcc32325a8628b87f0405f9cee9.tar.gz dedo-12af751e869acdcc32325a8628b87f0405f9cee9.tar.xz |
Merge pull request #444 from pmezard/doc-bucket-lifetime
bucket: document buckets are valid only during the transaction
-rw-r--r-- | bucket.go | 3 | ||||
-rw-r--r-- | tx.go | 3 |
2 files changed, 6 insertions, 0 deletions
@@ -99,6 +99,7 @@ func (b *Bucket) Cursor() *Cursor { // Bucket retrieves a nested bucket by name. // Returns nil if the bucket does not exist. +// The bucket instance is only valid for the lifetime of the transaction. func (b *Bucket) Bucket(name []byte) *Bucket { if b.buckets != nil { if child := b.buckets[string(name)]; child != nil { @@ -148,6 +149,7 @@ func (b *Bucket) openBucket(value []byte) *Bucket { // CreateBucket creates a new bucket at the given key and returns the new bucket. // Returns an error if the key already exists, if the bucket name is blank, or if the bucket name is too long. +// The bucket instance is only valid for the lifetime of the transaction. func (b *Bucket) CreateBucket(key []byte) (*Bucket, error) { if b.tx.db == nil { return nil, ErrTxClosed @@ -192,6 +194,7 @@ func (b *Bucket) CreateBucket(key []byte) (*Bucket, error) { // CreateBucketIfNotExists creates a new bucket if it doesn't already exist and returns a reference to it. // Returns an error if the bucket name is blank, or if the bucket name is too long. +// The bucket instance is only valid for the lifetime of the transaction. func (b *Bucket) CreateBucketIfNotExists(key []byte) (*Bucket, error) { child, err := b.CreateBucket(key) if err == ErrBucketExists { @@ -87,18 +87,21 @@ func (tx *Tx) Stats() TxStats { // Bucket retrieves a bucket by name. // Returns nil if the bucket does not exist. +// The bucket instance is only valid for the lifetime of the transaction. func (tx *Tx) Bucket(name []byte) *Bucket { return tx.root.Bucket(name) } // CreateBucket creates a new bucket. // Returns an error if the bucket already exists, if the bucket name is blank, or if the bucket name is too long. +// The bucket instance is only valid for the lifetime of the transaction. func (tx *Tx) CreateBucket(name []byte) (*Bucket, error) { return tx.root.CreateBucket(name) } // CreateBucketIfNotExists creates a new bucket if it doesn't already exist. // Returns an error if the bucket name is blank, or if the bucket name is too long. +// The bucket instance is only valid for the lifetime of the transaction. func (tx *Tx) CreateBucketIfNotExists(name []byte) (*Bucket, error) { return tx.root.CreateBucketIfNotExists(name) } |