Skip to content

InMemoryRetentionPolicyStore

Namespace AgentPrism · Assembly AgentPrism.Core.dll

The default implementation that keeps retention policies and run history in process memory.

public sealed class InMemoryRetentionPolicyStore : IRetentionPolicyStore

objectInMemoryRetentionPolicyStore

IRetentionPolicyStore

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

For single-process deployments and tests. UsePostgreSql, UseSqlServer, or UseSqlite replaces it with a SQL implementation.

public InMemoryRetentionPolicyStore()

AppendRunProgressAsync(Guid, long, long, CancellationToken)

Section titled “ AppendRunProgressAsync(Guid, long, long, CancellationToken)”

Increments an in-progress run’s counters. Called after each batch.

public ValueTask AppendRunProgressAsync(Guid runId, long deletedDelta, long archivedDelta, CancellationToken cancellationToken = default)

runId Guid

The run identifier.

deletedDelta long

The number of rows deleted in this batch.

archivedDelta long

The number of rows archived in this batch.

cancellationToken CancellationToken

The cancellation token.

ValueTask

The completion task.

CompleteRunAsync(Guid, DateTimeOffset, string?, CancellationToken)

Section titled “ CompleteRunAsync(Guid, DateTimeOffset, string?, CancellationToken)”

Finalizes a run.

public ValueTask CompleteRunAsync(Guid runId, DateTimeOffset completedAt, string? errorMessage, CancellationToken cancellationToken = default)

runId Guid

The run identifier.

completedAt DateTimeOffset

The completion time (UTC).

errorMessage string?

The error message; null if successful.

cancellationToken CancellationToken

The cancellation token.

ValueTask

The completion task.

CreateRunAsync(RetentionRun, CancellationToken)

Section titled “ CreateRunAsync(RetentionRun, CancellationToken)”

Opens a new cleanup run.

public ValueTask<RetentionRun> CreateRunAsync(RetentionRun run, CancellationToken cancellationToken = default)

run RetentionRun

The starting record. RetentionRun.CompletedAt is ignored.

cancellationToken CancellationToken

The cancellation token.

ValueTask<RetentionRun>

The created record.

DeletePolicyAsync(string, string, CancellationToken)

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

Deletes a policy.

public ValueTask<bool> DeletePolicyAsync(string tenantId, string target, CancellationToken cancellationToken = default)

tenantId string

The tenant identifier.

target string

The target name.

cancellationToken CancellationToken

The cancellation token.

ValueTask<bool>

true if the delete happened.

GetPolicyAsync(string, string, CancellationToken)

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

Looks up a single target’s policy within the tenant, falling back to the "*" tenant-wide policy.

public ValueTask<RetentionPolicy?> GetPolicyAsync(string tenantId, string target, CancellationToken cancellationToken = default)

tenantId string

The tenant identifier.

target string

The target name.

cancellationToken CancellationToken

The cancellation token.

ValueTask<RetentionPolicy?>

The policy; null if none exists at either level.

ListPoliciesAsync(string, CancellationToken)

Section titled “ ListPoliciesAsync(string, CancellationToken)”

Lists all of a tenant’s policies (and the "*" tenant-wide ones).

public ValueTask<IReadOnlyList<RetentionPolicy>> ListPoliciesAsync(string tenantId, CancellationToken cancellationToken = default)

tenantId string

The tenant identifier.

cancellationToken CancellationToken

The cancellation token.

ValueTask<IReadOnlyList<RetentionPolicy>>

The policies.

ListRunsAsync(string, string?, int, int, CancellationToken)

Section titled “ ListRunsAsync(string, string?, int, int, CancellationToken)”

Lists a tenant’s run history. The newest record is returned first.

public ValueTask<IReadOnlyList<RetentionRun>> ListRunsAsync(string tenantId, string? target, int skip, int take, CancellationToken cancellationToken = default)

tenantId string

The tenant identifier.

target string?

Fetches only this target’s runs; all if null.

skip int

The number of records to skip.

take int

The maximum number of records to fetch.

cancellationToken CancellationToken

The cancellation token.

ValueTask<IReadOnlyList<RetentionRun>>

The records.

SavePolicyAsync(RetentionPolicy, CancellationToken)

Section titled “ SavePolicyAsync(RetentionPolicy, CancellationToken)”

Creates or updates a policy.

public ValueTask<RetentionPolicy> SavePolicyAsync(RetentionPolicy policy, CancellationToken cancellationToken = default)

policy RetentionPolicy

The policy.

cancellationToken CancellationToken

The cancellation token.

ValueTask<RetentionPolicy>

The saved policy.