Path: redb/redb.Core/Data/IKeyGenerator.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Core/Data/IKeyGenerator.cs
----
using System.Threading.Tasks;
using System.Threading;
namespace redb.Core.Data
{
///
/// Key generator abstraction for generating unique IDs.
/// Replaces EF Core's automatic ID generation.
///
public interface IKeyGenerator
{
///
/// Generate next unique ID for objects.
/// Uses database sequence or other mechanism.
///
/// Next unique ID.
Task NextObjectIdAsync(CancellationToken cancellationToken = default);
///
/// Generate next unique ID for values.
/// Uses database sequence or other mechanism.
///
/// Next unique ID.
Task NextValueIdAsync(CancellationToken cancellationToken = default);
///
/// Generate batch of object IDs for bulk operations.
/// More efficient than calling NextObjectIdAsync multiple times.
///
/// Number of IDs to generate.
/// Array of unique IDs.
/// Cancels the operation; see the cancellation contract in the plan (OCE only, rollback always completes).
Task NextObjectIdBatchAsync(int count, CancellationToken cancellationToken = default);
///
/// Generate batch of value IDs for bulk operations.
/// More efficient than calling NextValueIdAsync multiple times.
///
/// Number of IDs to generate.
/// Array of unique IDs.
/// Cancels the operation; see the cancellation contract in the plan (OCE only, rollback always completes).
Task NextValueIdBatchAsync(int count, CancellationToken cancellationToken = default);
}
}