aboutsummaryrefslogtreecommitdiff
path: root/bucket.go
blob: 1ce901fbd689427904de650668ac8aa4a8d43ac3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package bolt

type Bucket struct {
	*bucket
	name        string
	transaction *Transaction
	cursors     []*Cursor
}

type bucket struct {
	root  pgid
}

// Get retrieves the value for a key in the bucket.
func (b *Bucket) Get(key []byte) []byte {
	return b.cursor().Get(key)
}

// Cursor creates a new cursor for this bucket.
func (b *Bucket) Cursor() *Cursor {
	c := b.cursor()
	b.cursors = append(b.cursors, c)
	return c
}

// cursor creates a new untracked cursor for this bucket.
func (b *Bucket) cursor() *Cursor {
	return &Cursor{
		bucket: b,
		stack:  make([]elem, 0),
	}
}