Class RedbKeyGeneratorBase

Namespace: redb.Core.Data
Assembly: redb.Core.dll

Base class for key generation with domain-isolated caching.
Each domain (typically one per database connection) has isolated cache.
Instance is bound to specific domain, static data is shared.

public abstract class RedbKeyGeneratorBase : IKeyGenerator

Inheritance

Object→RedbKeyGeneratorBase

Implements

Derived

Properties

Domain

Cache domain this instance is bound to.

public string Domain { get; }

IssuedHighWater

The highest id this process has handed out for this domain (), 0 before the first.

protected long IssuedHighWater { get; }

Methods

ClearAllCaches()

Clear cache for all domains (for testing/reset).

public static void ClearAllCaches()

ClearCache()

Clear cache for this domain.

public void ClearCache()

GenerateKeysAsync(int)

Generate batch of keys from database sequence.

protected abstract Task<List<long>> GenerateKeysAsync(int count)

NextObjectIdAsync()

Get next object ID (uses shared static cache).

public Task<long> NextObjectIdAsync()

NextObjectIdAsync(CancellationToken)

Get next object ID (uses shared static cache).

public Task<long> NextObjectIdAsync(CancellationToken cancellationToken = default)

NextObjectIdBatchAsync(int, CancellationToken)

Get batch of object IDs.

public Task<long[]> NextObjectIdBatchAsync(int count, CancellationToken cancellationToken = default)

NextObjectIdBatchAsync(int)

Get batch of object IDs.

public Task<long[]> NextObjectIdBatchAsync(int count)

NextValueIdAsync()

Get next value ID (uses shared static cache).

public Task<long> NextValueIdAsync()

NextValueIdAsync(CancellationToken)

Get next value ID (uses shared static cache).

public Task<long> NextValueIdAsync(CancellationToken cancellationToken = default)

NextValueIdBatchAsync(int, CancellationToken)

Get batch of value IDs.

public Task<long[]> NextValueIdBatchAsync(int count, CancellationToken cancellationToken = default)

NextValueIdBatchAsync(int)

Get batch of value IDs.

public Task<long[]> NextValueIdBatchAsync(int count)

RecordIssued(long)

Raises to top, the highest id of a range just handed out.

protected void RecordIssued(long top)

SetCacheSize(int)

Set cache size (default 10000).

public static void SetCacheSize(int size)

TryGenerateKeysInAmbientTransactionAsync(int)

Provider hook for a refill that must not use a SEPARATE connection, bypassing the shared cache:

protected virtual Task<List<long>?> TryGenerateKeysInAmbientTransactionAsync(int count)

Constructors