Skip to content

InMemoryJobScheduleStore

Namespace AgentPrism · Assembly AgentPrism.Core.dll

A store that keeps schedule definitions in process memory.

public sealed class InMemoryJobScheduleStore : IJobScheduleStore

objectInMemoryJobScheduleStore

IJobScheduleStore

object.GetType(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

Limits: process lifetime and a single node. Use AgentPrism.PostgreSql in production.

public InMemoryJobScheduleStore()

DeleteAsync(string, string, CancellationToken)

Section titled “ DeleteAsync(string, string, CancellationToken)”

Deletes the schedule.

public ValueTask<bool> DeleteAsync(string tenantId, string name, CancellationToken cancellationToken = default)

tenantId string

The tenant identifier.

name string

The schedule name.

cancellationToken CancellationToken

The cancellation token.

ValueTask<bool>

true if the delete happened.

GetAsync(string, string, CancellationToken)

Section titled “ GetAsync(string, string, CancellationToken)”

Fetches the schedule with the given name.

public ValueTask<JobSchedule?> GetAsync(string tenantId, string name, CancellationToken cancellationToken = default)

tenantId string

The tenant identifier.

name string

The schedule name.

cancellationToken CancellationToken

The cancellation token.

ValueTask<JobSchedule?>

The schedule; null if it does not exist.

Lists all of a tenant’s schedules, by name.

public ValueTask<IReadOnlyList<JobSchedule>> ListAsync(string tenantId, CancellationToken cancellationToken = default)

tenantId string

The tenant identifier.

cancellationToken CancellationToken

The cancellation token.

ValueTask<IReadOnlyList<JobSchedule>>

The schedules.

ListDueAsync(DateTimeOffset, CancellationToken)

Section titled “ ListDueAsync(DateTimeOffset, CancellationToken)”

Lists the schedules of every tenant that are due to run (NextRunAt <= asOfUtc), enabled, and carry a cron expression.

public ValueTask<IReadOnlyList<JobSchedule>> ListDueAsync(DateTimeOffset asOfUtc, CancellationToken cancellationToken = default)

asOfUtc DateTimeOffset

The comparison moment (UTC).

cancellationToken CancellationToken

The cancellation token.

ValueTask<IReadOnlyList<JobSchedule>>

The due schedules.

SaveAsync(JobSchedule, CancellationToken)

Section titled “ SaveAsync(JobSchedule, CancellationToken)”

Creates or updates the schedule (name + tenant is unique).

public ValueTask<JobSchedule> SaveAsync(JobSchedule schedule, CancellationToken cancellationToken = default)

schedule JobSchedule

The schedule to save.

cancellationToken CancellationToken

The cancellation token.

ValueTask<JobSchedule>

The saved schedule.

TryClaimNextRunAsync(Guid, DateTimeOffset, DateTimeOffset, DateTimeOffset, CancellationToken)

Section titled “ TryClaimNextRunAsync(Guid, DateTimeOffset, DateTimeOffset, DateTimeOffset, CancellationToken)”

Tries to atomically advance a schedule’s JobSchedule.NextRunAt field (compare-and-swap).

public ValueTask<bool> TryClaimNextRunAsync(Guid scheduleId, DateTimeOffset expectedNextRunAt, DateTimeOffset newNextRunAt, DateTimeOffset ranAt, CancellationToken cancellationToken = default)

scheduleId Guid

The schedule identifier.

expectedNextRunAt DateTimeOffset

The expected current value. If another instance has already advanced it, the value does not match and the operation fails — this is how two overlapping scheduling triggers are prevented.

newNextRunAt DateTimeOffset

The new next-run time.

ranAt DateTimeOffset

The time this trigger happened (UTC).

cancellationToken CancellationToken

The cancellation token.

ValueTask<bool>

true if the claim succeeded.