Table of Contents

Class OptimisticTransactionOptions

Namespace
RocksDbNet
Assembly
RocksDb.Net.dll

Per-transaction settings for BeginTransaction(WriteOptions?, OptimisticTransactionOptions?). Maps to rocksdb_optimistictransaction_options_t.

public sealed class OptimisticTransactionOptions : RocksDbHandle, IDisposable
Inheritance
OptimisticTransactionOptions
Implements
Inherited Members

Remarks

Deliberately smaller than TransactionOptions. There are no lock timeouts or deadlock settings here because an optimistic transaction takes no locks while it runs, which is the point of it.

Constructors

OptimisticTransactionOptions()

Creates options with RocksDb's defaults.

public OptimisticTransactionOptions()

Properties

SetSnapshot

Pin a snapshot when the transaction begins, so its reads see the database as it was at that moment.

public bool SetSnapshot { get; set; }

Property Value

bool

Remarks

This changes what conflicts. Without it, validation compares against the state at each read, so a transaction that read a key early and committed late tolerates a change in between. With it, the comparison is against the moment the transaction began, and any change to a key it read is a conflict.

The stricter behaviour is what a read-modify-write usually wants, and is the reason to reach for this rather than leave it off.

Methods

DisposeHandle()

Releases the native handle. Called during disposal.

protected override void DisposeHandle()

Remarks

Protected rather than public: it destroys the native object without marking this instance disposed or clearing the handle, so calling it from outside and then disposing normally would free the same pointer twice. It was the most Dispose-looking member on the type. Callers want Dispose().