MCPcopy
hub / github.com/etcd-io/bbolt / Get

Method Get

bucket.go:433–446  ·  view source on GitHub ↗

Get retrieves the value for a key in the bucket. Returns a nil value if the key does not exist or if the key is a nested bucket. The returned value is only valid for the life of the transaction. The returned memory is owned by bbolt and must never be modified; writing to this memory might corrupt th

(key []byte)

Source from the content-addressed store, hash-verified

431// The returned value is only valid for the life of the transaction.
432// The returned memory is owned by bbolt and must never be modified; writing to this memory might corrupt the database.
433func (b *Bucket) Get(key []byte) []byte {
434 k, v, flags := b.Cursor().seek(key)
435
436 // Return nil if this is a bucket.
437 if (flags & common.BucketLeafFlag) != 0 {
438 return nil
439 }
440
441 // If our target node isn't the same key as what's passed in then return nil.
442 if !bytes.Equal(key, k) {
443 return nil
444 }
445 return v
446}
447
448// Put sets the value for a key in the bucket.
449// If the key exist then its previous value will be overwritten.

Callers 15

TestBucket_Get_FromNodeFunction · 0.45
TestBucket_PutFunction · 0.45
TestBucket_Put_RepeatFunction · 0.45
TestBucket_Put_LargeFunction · 0.45
TestBucket_DeleteFunction · 0.45
TestBucket_Delete_LargeFunction · 0.45
TestBucket_NestedFunction · 0.45
TestBucket_Put_SingleFunction · 0.45
TestBucket_Put_MultipleFunction · 0.45

Calls 2

CursorMethod · 0.95
seekMethod · 0.80

Tested by 15

TestBucket_Get_FromNodeFunction · 0.36
TestBucket_PutFunction · 0.36
TestBucket_Put_RepeatFunction · 0.36
TestBucket_Put_LargeFunction · 0.36
TestBucket_DeleteFunction · 0.36
TestBucket_Delete_LargeFunction · 0.36
TestBucket_NestedFunction · 0.36
TestBucket_Put_SingleFunction · 0.36
TestBucket_Put_MultipleFunction · 0.36