mirror of
https://github.com/luxfi/zapdb.git
synced 2026-07-27 06:54:45 +00:00
feat(txn): add public method for getting the value of discarded field (#1788)
This commit is contained in:
@@ -760,6 +760,11 @@ func (txn *Txn) ReadTs() uint64 {
|
||||
return txn.readTs
|
||||
}
|
||||
|
||||
// Discarded returns the discarded value of the transaction.
|
||||
func (txn *Txn) Discarded() bool {
|
||||
return txn.discarded
|
||||
}
|
||||
|
||||
// NewTransaction creates a new transaction. Badger supports concurrent execution of transactions,
|
||||
// providing serializable snapshot isolation, avoiding write skews. Badger achieves this by tracking
|
||||
// the keys read and at Commit time, ensuring that these read keys weren't concurrently modified by
|
||||
|
||||
+12
@@ -952,3 +952,15 @@ func TestConflict(t *testing.T) {
|
||||
runTest(t, testAndSetItr)
|
||||
})
|
||||
}
|
||||
|
||||
func TestTxnGetters(t *testing.T) {
|
||||
t.Run("TxnDiscarded", func(t *testing.T) {
|
||||
runBadgerTest(t, nil, func(t *testing.T, db *DB) {
|
||||
txn := db.NewTransaction(true)
|
||||
require.Equal(t, false, txn.Discarded())
|
||||
|
||||
txn.Discard()
|
||||
require.Equal(t, true, txn.Discarded())
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user