MCPcopy
hub / github.com/dgraph-io/badger / View

Method View

txn.go:790–800  ·  view source on GitHub ↗

View executes a function creating and managing a read-only transaction for the user. Error returned by the function is relayed by the View method. If View is used with managed transactions, it would assume a read timestamp of MaxUint64.

(fn func(txn *Txn) error)

Source from the content-addressed store, hash-verified

788// returned by the function is relayed by the View method.
789// If View is used with managed transactions, it would assume a read timestamp of MaxUint64.
790func (db *DB) View(fn func(txn *Txn) error) error {
791 var txn *Txn
792 if db.opt.managedTxns {
793 txn = db.NewTransactionAt(math.MaxUint64, false)
794 } else {
795 txn = db.NewTransaction(false)
796 }
797 defer txn.Discard()
798
799 return fn(txn)
800}
801
802// Update executes a function, creating and managing a read-write transaction
803// for the user. Error returned by the function is relayed by the Update method.

Callers 15

runTestFunction · 0.95
deleteMoveKeysForMethod · 0.80
TestWriteBatchFunction · 0.80
TestManifestBasicFunction · 0.80
TestIteratePrefixFunction · 0.80
numKeysFunction · 0.80
TestWriteBatchManagedFunction · 0.80
TestWriteBatchDuplicateFunction · 0.80
GetMethod · 0.80
TestUpdateAndViewFunction · 0.80

Calls 3

NewTransactionAtMethod · 0.95
NewTransactionMethod · 0.95
DiscardMethod · 0.95

Tested by 15

TestWriteBatchFunction · 0.64
TestManifestBasicFunction · 0.64
TestIteratePrefixFunction · 0.64
numKeysFunction · 0.64
TestWriteBatchManagedFunction · 0.64
TestWriteBatchDuplicateFunction · 0.64
TestUpdateAndViewFunction · 0.64
TestExistsMoreFunction · 0.64
TestLoadFunction · 0.64