Skip to main content

managed_db

managed_db.go - Overview

This file provides functions to enable and manage transactions with explicit timestamp control within BadgerDB, specifically for "managed mode." This mode is intended for advanced use cases like Dgraph, where precise control over transaction timestamps is required.

Detailed Documentation

OpenManaged

Purpose: Opens a new BadgerDB instance configured for managed transactions.

Parameters:

  • opts (Options): Configuration options for the database.

Returns:

  • *DB: A pointer to the new DB instance.
  • error: An error, if any occurred during opening the database.

NewTransactionAt

Purpose: Creates a new transaction with a specified read timestamp.

Parameters:

  • readTs (uint64): The read timestamp for the transaction.
  • update (bool): Indicates whether the transaction will perform updates.

Returns:

  • *Txn: A pointer to the new transaction.

Panics: If managedTxns is not enabled in the DB options.

NewWriteBatchAt

Purpose: Creates a new write batch with a specified commit timestamp, intended for managed mode.

Parameters:

  • commitTs (uint64): The commit timestamp for the write batch.

Returns:

  • *WriteBatch: A pointer to the new write batch.

Panics: If managedTxns is not enabled in the DB options.

NewManagedWriteBatch

Purpose: Creates a new write batch for managed transactions.

Returns:

  • *WriteBatch: A pointer to the new write batch.

Panics: If managedTxns is not enabled in the DB options.

CommitAt

Purpose: Commits a transaction with a specified commit timestamp.

Parameters:

  • commitTs (uint64): The commit timestamp for the transaction.
  • callback (func(error)): A callback function to be executed after the commit.

Returns:

  • error: An error, if any occurred during commit.

Panics: If managedTxns is not enabled in the DB options.

SetDiscardTs

Purpose: Sets a discard timestamp, indicating that versions older than this timestamp can be discarded.

Parameters:

  • ts (uint64): The discard timestamp.

Panics: If managedTxns is not enabled in the DB options.

Code Examples

None

Getting Started Relevance