FdbDatabaseExtensions
Namespace: FoundationDB.Client · class
Provides a set of extensions methods shared by all FoundationDB database implementations.
Methods
AtomicAdd
static Task AtomicAdd(IFdbRetryable db, Slice key, Slice value, CancellationToken ct)
Atomically add to the value of a single key in the database, using a dedicated transaction.
Use this method only if you intend to perform a single operation inside your execution context (ex: HTTP request). If you need to combine multiple read or write operations, consider using on of the multiple or overrides.
AtomicBitAnd
static Task AtomicBitAnd(IFdbRetryable db, Slice key, Slice value, CancellationToken ct)
Atomically perform a bitwise AND to the value of a single key in the database, using a dedicated transaction.
Use this method only if you intend to perform a single operation inside your execution context (ex: HTTP request). If you need to combine multiple read or write operations, consider using on of the multiple or overrides.
AtomicBitOr
static Task AtomicBitOr(IFdbRetryable db, Slice key, Slice value, CancellationToken ct)
Atomically perform a bitwise OR to the value of a single key in the database, using a dedicated transaction.
Use this method only if you intend to perform a single operation inside your execution context (ex: HTTP request). If you need to combine multiple read or write operations, consider using on of the multiple or overrides.
AtomicBitXor
static Task AtomicBitXor(IFdbRetryable db, Slice key, Slice value, CancellationToken ct)
Atomically perform a bitwise XOR to the value of a single key in the database, using a dedicated transaction.
Use this method only if you intend to perform a single operation inside your execution context (ex: HTTP request). If you need to combine multiple read or write operations, consider using on of the multiple or overrides.
AtomicCompareAndClear
static Task AtomicCompareAndClear(IFdbRetryable db, Slice key, Slice comparand, CancellationToken ct)
Atomically compare and optionally clear the value of a single key in the database, using a dedicated transaction.
Use this method only if you intend to perform a single operation inside your execution context (ex: HTTP request). If you need to combine multiple read or write operations, consider using on of the multiple or overrides.
AtomicMax
static Task AtomicMax(IFdbRetryable db, Slice key, Slice value, CancellationToken ct)
Atomically update a value if it is larger than the value in the database, using a dedicated transaction.
Use this method only if you intend to perform a single operation inside your execution context (ex: HTTP request). If you need to combine multiple read or write operations, consider using on of the multiple or overrides.
AtomicMin
static Task AtomicMin(IFdbRetryable db, Slice key, Slice value, CancellationToken ct)
Atomically update a value if it is smaller than the value in the database, using a dedicated transaction.
Use this method only if you intend to perform a single operation inside your execution context (ex: HTTP request). If you need to combine multiple read or write operations, consider using on of the multiple or overrides.
BeginReadOnlyTransaction
static IFdbReadOnlyTransaction BeginReadOnlyTransaction(IFdbDatabase db, CancellationToken ct)
Start a new read-only transaction on this database
db— Database instancect— Optional cancellation token that can abort all pending async operations started by this transaction.
Returns: New transaction instance that can read from the database.
You MUST call Dispose() on the transaction when you are done with it. You SHOULD wrap it in a 'using' statement to ensure that it is disposed in all cases.
BeginReadOnlyTransactionAsync
static ValueTask<IFdbReadOnlyTransaction> BeginReadOnlyTransactionAsync(IFdbDatabase db, CancellationToken ct)
Start a new read-only transaction on this database
db— Database instancect— Optional cancellation token that can abort all pending async operations started by this transaction.
Returns: New transaction instance that can read from the database.
You MUST call Dispose() on the transaction when you are done with it. You SHOULD wrap it in a 'using' statement to ensure that it is disposed in all cases.
BeginTransaction
static IFdbTransaction BeginTransaction(IFdbDatabase db, CancellationToken ct)
Start a new transaction on this database
db— Database instancect— Optional cancellation token that can abort all pending async operations started by this transaction.
Returns: New transaction instance that can read from or write to the database.
You MUST call Dispose() on the transaction when you are done with it. You SHOULD wrap it in a 'using' statement to ensure that it is disposed in all cases.
BeginTransactionAsync
static ValueTask<IFdbTransaction> BeginTransactionAsync(IFdbDatabase db, CancellationToken ct)
Start a new transaction on this database
db— Database instancect— Optional cancellation token that can abort all pending async operations started by this transaction.
Returns: New transaction instance that can read from or write to the database.
You MUST call Dispose() on the transaction when you are done with it. You SHOULD wrap it in a 'using' statement to ensure that it is disposed in all cases.
ClearAsync
static Task ClearAsync(IFdbRetryable db, Slice key, CancellationToken ct)
Clear a single key in the database, using a dedicated transaction.
Use this method only if you intend to perform a single operation inside your execution context (ex: HTTP request). If you need to combine multiple read or write operations, consider using on of the multiple or overrides.
ClearRangeAsync
static Task ClearRangeAsync(IFdbRetryable db, KeyRange range, CancellationToken ct)
Clear a single range in the database, using a dedicated transaction.
Use this method only if you intend to perform a single operation inside your execution context (ex: HTTP request). If you need to combine multiple read or write operations, consider using on of the multiple or overrides.
static Task ClearRangeAsync(IFdbRetryable db, Slice beginKeyInclusive, Slice endKeyExclusive, CancellationToken ct)
Clear a single range in the database, using a dedicated transaction.
Use this method only if you intend to perform a single operation inside your execution context (ex: HTTP request). If you need to combine multiple read or write operations, consider using on of the multiple or overrides.
GetAsync
static Task<Slice> GetAsync(IFdbReadOnlyRetryable db, Slice key, CancellationToken ct)
Read a single key from the database, using a dedicated transaction.
Use this method only if you intend to perform a single operation inside your execution context (ex: HTTP request). If you need to read several keys at once, use a version of . If you need to combine multiple read or write operations, consider using on of the multiple or overrides.
GetKeyAsync
static Task<Slice> GetKeyAsync(IFdbReadOnlyRetryable db, KeySelector keySelector, CancellationToken ct)
Resolve a single key selector from the database, using a dedicated transaction.
Use this method only if you intend to perform a single operation inside your execution context (ex: HTTP request). If you need to combine multiple read or write operations, consider using on of the multiple or overrides.
GetKeysAsync
static Task<Slice[]> GetKeysAsync(IFdbReadOnlyRetryable db, KeySelector[] keySelectors, CancellationToken ct)
Resolve a list of key selectors from the database, using a dedicated transaction.
Use this method only if you intend to perform a single operation inside your execution context (ex: HTTP request). If you need to combine multiple read or write operations, consider using on of the multiple or overrides.
static Task<Slice[]> GetKeysAsync(IFdbReadOnlyRetryable db, IEnumerable<KeySelector> keySelectors, CancellationToken ct)
Resolve a sequence of key selectors from the database, using a dedicated transaction.
Use this method only if you intend to perform a single operation inside your execution context (ex: HTTP request). If you need to combine multiple read or write operations, consider using on of the multiple or overrides.
GetRangeAsync
static Task<FdbRangeChunk> GetRangeAsync(IFdbReadOnlyRetryable db, KeySelector beginInclusive, KeySelector endExclusive, FdbRangeOptions options, int iteration, CancellationToken ct)
Read a single page of a range query from the database, using a dedicated transaction.
Use this method only if you intend to perform a single operation inside your execution context (ex: HTTP request). If you need to combine multiple read or write operations, consider using on of the multiple or overrides.
GetServerProtocolAsync
static Task<ulong> GetServerProtocolAsync(IFdbDatabase db, CancellationToken ct)
Return the protocol version reported by the coordinator the client is connected to.
GetServerProtocolVersionAsync
static Task<FdbProtocolVersion> GetServerProtocolVersionAsync(IFdbDatabase db, CancellationToken ct)
Returns the protocol version reported by the coordinator this client is connected to.
db— Database instancect— Token used to cancel the operation.
Returns: Task that returns the current protocol version
This will never complete if the remote server is running a protocol from FDB 5.0 or older.
GetTenant
static IFdbTenant GetTenant(IFdbDatabase db, Slice name)
static IFdbTenant GetTenant(IFdbDatabase db, ReadOnlySpan<byte> name)
static IFdbTenant GetTenant<TTuple>(IFdbDatabase db, TTuple name)
static IFdbTenant GetTenant<T1>(IFdbDatabase db, (T1) name)
static IFdbTenant GetTenant<T1, T2>(IFdbDatabase db, (T1, T2) name)
static IFdbTenant GetTenant<T1, T2, T3>(IFdbDatabase db, (T1, T2, T3) name)
static IFdbTenant GetTenant<T1, T2, T3, T4>(IFdbDatabase db, (T1, T2, T3, T4) name)
static IFdbTenant GetTenant<T1, T2, T3, T4, T5>(IFdbDatabase db, (T1, T2, T3, T4, T5) name)
GetValuesAsync
static Task<Slice[]> GetValuesAsync(IFdbReadOnlyRetryable db, Slice[] keys, CancellationToken ct)
Read a list of keys from the database, using a dedicated transaction.
Use this method only if you intend to perform a single operation inside your execution context (ex: HTTP request). If you need to combine multiple read or write operations, consider using on of the multiple or overrides.
static Task<Slice[]> GetValuesAsync(IFdbReadOnlyRetryable db, IEnumerable<Slice> keys, CancellationToken ct)
Read a sequence of keys from the database, using a dedicated transaction.
Use this method only if you intend to perform a single operation inside your execution context (ex: HTTP request). If you need to combine multiple read or write operations, consider using on of the multiple or overrides.
SetAsync
static Task SetAsync(IFdbRetryable db, Slice key, Slice value, CancellationToken ct)
Set the value of a single key in the database, using a dedicated transaction.
Use this method only if you intend to perform a single operation inside your execution context (ex: HTTP request). If you need to combine multiple read or write operations, consider using on of the multiple or overrides.
SetValuesAsync
static Task SetValuesAsync(IFdbRetryable db, IEnumerable<KeyValuePair<Slice, Slice>> items, CancellationToken ct)
Set the values of a sequence of keys in the database, using a dedicated transaction.
Use this method only if you intend to perform a single operation inside your execution context (ex: HTTP request). If you need to combine multiple read or write operations, consider using on of the multiple or overrides.
static Task SetValuesAsync(IFdbRetryable db, IEnumerable<(Slice, Slice)> items, CancellationToken ct)
Set the values of a sequence of keys in the database, using a dedicated transaction.
Use this method only if you intend to perform a single operation inside your execution context (ex: HTTP request). If you need to combine multiple read or write operations, consider using on of the multiple or overrides.
WithDataCenterId
static IFdbDatabaseOptions WithDataCenterId(IFdbDatabaseOptions options, string hexId)
Specify the datacenter ID that was passed to fdbserver processes running in the same datacenter as this client, for better location-aware load balancing.
options— Database instancehexId— Hexadecimal ID
static IFdbDatabaseOptions WithDataCenterId(IFdbDatabaseOptions options, ReadOnlySpan<char> hexId)
Specify the datacenter ID that was passed to fdbserver processes running in the same datacenter as this client, for better location-aware load balancing.
options— Database instancehexId— Hexadecimal ID
WithDefaultMaxRetryDelay
static IFdbDatabaseOptions WithDefaultMaxRetryDelay(IFdbDatabaseOptions options, TimeSpan timeout)
Set the default maximum retry delay value for all transactions created from this database instance.
Only effective for future transactions
static IFdbDatabaseOptions WithDefaultMaxRetryDelay(IFdbDatabaseOptions options, int timeout)
Set the default maximum retry delay value (in milliseconds) for all transactions created from this database instance.
Only effective for future transactions
WithDefaultRetryLimit
static IFdbDatabaseOptions WithDefaultRetryLimit(IFdbDatabaseOptions options, int limit)
Set the default Retry Limit value for all transactions created from this database instance.
Only effective for future transactions
WithDefaultTimeout
static IFdbDatabaseOptions WithDefaultTimeout(IFdbDatabaseOptions options, TimeSpan timeout)
Set the default Timeout value for all transactions created from this database instance.
Only effective for future transactions
static IFdbDatabaseOptions WithDefaultTimeout(IFdbDatabaseOptions options, int timeout)
Set the default Timeout value (in milliseconds) for all transactions created from this database instance.
Only effective for future transactions
WithLocationCacheSize
static IFdbDatabaseOptions WithLocationCacheSize(IFdbDatabaseOptions options, int size)
Set the size of the client location cache. Raising this value can boost performance in very large databases where clients access data in a near-random pattern. Defaults to 100000.
options— Database instancesize— Max location cache entries
WithMachineId
static IFdbDatabaseOptions WithMachineId(IFdbDatabaseOptions options, string hexId)
Specify the machine ID that was passed to fdbserver processes running on the same machine as this client, for better location-aware load balancing.
options— Database instancehexId— Hexadecimal ID
static IFdbDatabaseOptions WithMachineId(IFdbDatabaseOptions options, ReadOnlySpan<char> hexId)
Specify the machine ID that was passed to fdbserver processes running on the same machine as this client, for better location-aware load balancing.
options— Database instancehexId— Hexadecimal ID
WithMaxWatches
static IFdbDatabaseOptions WithMaxWatches(IFdbDatabaseOptions options, int count)
Set the maximum number of watches allowed to be outstanding on a database connection. Increasing this number could result in increased resource usage. Reducing this number will not cancel any outstanding watches. Defaults to 10000 and cannot be larger than 1000000.
options— Database instancecount— Max outstanding watches
WithTracing
static IFdbDatabaseOptions WithTracing(IFdbDatabaseOptions options, FdbTracingOptions tracing)
Specify the default tracing options for all transactions created from this database
options— Database instancetracing— Tracing options