IFdbLayer<TState, TOptions>

Namespace: FoundationDB.Client · interface

Implements: IFdbLayer

Represents a FoundationDB Layer that uses a metadata cache to speed up operations

Remarks

A typical Layer will be a thin wrapper over a subspace location and some options/encoders/helpers

When a transaction wants to interact with the Layer, is must first call Resolve(...) at least once within the transaction, and then call any method necessary on that state object.

Storing and reusing state instances outside the transaction is NOT ALLOWED.

The Layer implementation should try to cache complex metadata in order to reduce the latency.

If the layer uses lower level layers, it should NOT attempt to cache these in its own state, and instead call these layer's own Resolve methods

This means that layers should not cache the TState type itself, and instead cache a "TCache" object, and create a new "TState" instance for each new transaction, that wraps the TCache

Methods

Resolve

ValueTask<TState> Resolve(IFdbReadOnlyTransaction tr, TOptions options)

Resolve the state for this layer, applicable to the current transaction

  • tr — Transaction that will be used to interact with this layer
  • options — Optional parameter that depends on the type of layer

Returns: State handler that is valid only for this transaction.

Even though most layers will attempt to cache complex metadata, it is best practice to not call this method multiple times within the same transaction. Accessing the returned state instance outside the transaction scope (after commit, in the next retry loop attempt, ...) has undefined behavior and should be avoided.