Class: Isomorfeus::Hamster::Transaction

Inherits:
Object
  • Object
show all
Defined in:
ext/isomorfeus_hamster_ext/isomorfeus_hamster.c

Instance Method Summary collapse

Instance Method Details

#abortObject

Note:

After aborting a transaction, no further database operations should be done in the block. Any cursors created in the context of the transaction will no longer be valid.

Abort a transaction in process. Any subtransactions of this transaction will be aborted as well.

Examples:

Single transaction

env.transaction do |txn|
  # ... modify the databases ...
  txn.abort
  # modifications are rolled back
end

Child transactions

env.transaction do |txn1|
  env.transaction.do |txn2|
     txn1.abort      # txn1 and txn2 are both aborted
  end
end


105
106
107
108
# File 'ext/isomorfeus_hamster_ext/isomorfeus_hamster.c', line 105

static VALUE transaction_abort(VALUE self) {
        transaction_finish(self, 0);
        return Qnil;
}

#commitObject

Note:

After committing a transaction, no further database operations should be done in the block. Any cursors created in the context of the transaction will no longer be valid.

Commit a transaction in process. Any subtransactions of this transaction will be committed as well.

One does not normally need to call commit explicitly; a commit is performed automatically when the block supplied to Environment#transaction exits normally.

Examples:

Single transaction

env.transaction do |txn|
  # ... modify the databases ...
  txn.commit
end

Child transactions

env.transaction do |txn1|
  env.transaction.do |txn2|
     txn1.commit      # txn1 and txn2 are both committed
  end
end


78
79
80
81
# File 'ext/isomorfeus_hamster_ext/isomorfeus_hamster.c', line 78

static VALUE transaction_commit(VALUE self) {
        transaction_finish(self, 1);
        return Qnil;
}

#envEnvironment

Returns the environment in which this transaction is running.

Examples:

env.transaction do |t|
  env == t.env
  # should be true
end

Returns:

  • (Environment)

    the environment in which this transaction is running.



119
120
121
122
# File 'ext/isomorfeus_hamster_ext/isomorfeus_hamster.c', line 119

static VALUE transaction_env(VALUE self) {
        TRANSACTION(self, transaction);
        return transaction->env;
}